Graph object (Multivariate Analysis Toolbox for MatlabŪ)

written by: Liran Carmel

Last modified: 0:48, Fri 10-Sep-2010

General Description
This object describes a mathematical entity known as a (undirected) graph. A graph is written as G(V,E), where V is a set of nodes, and E a set of edges connecting them. In a graph object the nodes are assumed to be indexed by sequential integers, 1, 2, ..., n, with n being the number of nodes and stored at the field named no_nodes. Information about edges is stored in the field weights, which is just the n-by-n matrix W. If W(i,j) is nonzero, this means that an edge exists between nodes i and j. For unweighted graph, W is comprised only from the discrete values 0 and 1. If the graph is weighted, the weight of the edge (i,j) is given by W(i,j).

The nodes may be labeled, and this can be stored in the field node_name. Additionally, nodes can be weighted too, a property sometimes referred to as the node's mass. Therefore, these weights are stored in the field node_mass. The object allows for additional user-defined information to be associated with the node, by the mechanism of "customized fields".

Navigate to:     General Description     Class Structure     Class Construction     Class Functions

Class Structure
Each field can be accessed by the dot (.) operation, or by the GET function. The GET function can work on multiple instances simultaneously. Most fields, except for those that are Dependent, can be modified using the dot (.) operation, or by the SET function.
    Field Description Type Default Dedicated Get/Set Function  
    name name of object, should be short and used as identifier. This field will never be empty. string 'unnamed'    
    description verbal description of the class content. string ''    
    source verbal description of the source of information. string ''    
    type type of graph. string 'general graph'    
    node_name names of all nodes. cell array of strings {} nodenames  
    node_mass mass of each node. double vector []    
    node_cfield user-specific node customized fields. cell array of values {}    
    node_cfield_name names of node customized fields. cell array of strings {}    
    weights symmetric sparse weight matrix. double matrix []    
  Dependent no_nodes number of nodes in the graph. integer scalar 0 nonodes  
  Dependent no_node_cfields number of customized fields. integer scalar 0    
  Dependent no_edges number of edges in the graph. integer vector 0 noedges  

Class Construction
Empty instance (scalar)
an empty graph instance, with all fields initialized to their default values.
syntax: gr = graph;
Empty instance (matrix)
an array of empty graph instances.
syntax: gr = graph(size,'size');
Copy constructor
one graph instance is copied into another.
syntax: gr_destination = graph(gr_origin);
Construction by field names
an instance is formed by directly providing field values. Any field which is not dependent is permitted.
syntax: gr = graph(field_name, field_value, ...);
Construction by weights and masses
a graph is uniquely defined by a weight matrix, and a vector of node masses.
syntax: gr = graph(W, M);
Construction from a file
a graph is read from a matrix-market file.
syntax: gr = graph(filename);

List of Functions


computes the Laplacian of a graph.

Customized fields manipulations:

allocates a new customized field to a graph.
finds whether a customized field exists in a graph.
lists the customized fields in a GRAPH object.
retrieves a customized field from a graph.
sets values for a customized field of GRAPHs.


displays class content.

Information extraction:

finds the IDs of a list of nodes.


computes missing fields.

SET/GET functions:

get method
retrieves the name of the nodes in the graph.
retrieves the number of edges in GRAPH objects.
retrieves the number of nodes in GRAPH objects.
set method


replaces the indices of two nodes.


computes the eigenprojection of a graph.