mat_2_graph — graph from node-arc or node-node incidence matrix
g = mat_2_graph(a,directed,[mat])
sparse node-arc or node-node incidence matrix
integer, 0 (undirected graph) or 1 (directed graph)
optional string, 'node-arc' or
'node-node' matrix
mat_2_graph computes the graph
g corresponding to the node-arc or the node-node
incidence matrix a. Note that a checking is made to
insure that a is a sparse node-arc or node-node
incidence matrix of a directed (directed = 1) or
undirected (directed = 0) graph. If the optional
argument mat is omitted or is the string
'node-arc', a must be a node-arc matrix. If
mat is the string 'node-node', a
must be a node-node matrix.
// creating a directed graph with 13 nodes and 14 arcs.
ta=[1 1 2 7 8 9 10 10 10 11 12 13 13];
he=[2 10 7 8 9 7 7 11 13 12 13 9 10];
g=make_graph('foo',1,13,ta,he);
g.nodes.graphics.x=[40,33,29,63,146,233,75,42,114,156,237,260,159]
g.nodes.graphics.y=[7,61,103,142,145,143,43,120,145,18,36,107,107]
show_graph(g)
a=graph_2_mat(g);
g1=mat_2_graph(a,1);
g1.nodes.graphics.x=g.nodes.graphics.x; g1.nodes.graphics.y=g.nodes.graphics.y;
show_graph(g1,'new');
a=graph_2_mat(g,'node-node');
g1=mat_2_graph(a,1,'node-node');
g1.nodes.graphics.x=g.nodes.graphics.x; g1.nodes.graphics.y=g.nodes.graphics.y;
show_graph(g1,'new');