node-arc or node-node incidence matrix of a graph
a = graph_2_mat(g,mat)
optional string, 'node-arc' or 'node-node' matrix
sparse node-arc or node-node incidence matrix
graph_2_mat
computes the node-arc or the node-node incidence matrix
corresponding
to the graph g
.
If the optional argument mat
is omitted or is the string
'node-arc'
, the node-arc matrix is computed. If mat
is the string
'node-node'
, the node-node matrix is computed.
If n
is the number of nodes of the graph and
m
is the number of edges of the graph, the node-arc matrix is a Scilab
sparse matrix of size (n,m)
.
It is defined as follows. If the graph is directed:
a(i,j) = +1
if node i
is the tail of arc j
a(i,j) = -1
if node i
is the head of arc j
If the graph is undirected:
a(i,j) = 1
if node i
is the tail or the head of arc j
If n
is the number of nodes of the graph, the node-node matrix is a
Scilab sparse matrix of size (n,n)
.
It is defined as follows:
a(i,j) = 1
if there is an arc from node i
to node j
ta = [10,3,6,2,3,7,6,9,5,10,8,2,5,8,4,9,1,8,9,4,7] he = [3,6,10,6,2,6,9,7,3,5,2,5,8,4,9,8,4,1,2,7,10] g=make_graph('foo',1,10,ta,he); g.nodes.graphics.x = [398,333,212,312,132,208,46,445,301,69]; g.nodes.graphics.y = [54,217,179,12,245,133,95,283,92,170]; g.nodes.graphics.display='number'; show_graph(g); a=graph_2_mat(g,'node-node'); a=[['' string(1:10)];[string(1:10)' string(full(a))]] a=graph_2_mat(g); string(full(a))' | ![]() | ![]() |