transitive closure
g1 = trans_closure(g)
a graph data structure
The transitive closure of a graph is a graph which contains an edge from node u to node v whenever there is a directed path from u to v.
trans_closure
returns as a new graph
g1
the transitive closure of the graph
g
. This graph must be directed and connected. If
<name>
if the name of graph g
,
<name>_trans_closure
is the name of the
transitive closure.
ta=[2 3 3 5 3 4 4 5 8]; he=[1 2 4 2 6 6 7 7 4]; g=make_graph('foo',1,8,ta,he); g.nodes.graphics.x=[129 200 283 281 128 366 122 333]; g.nodes.graphics.y=[61 125 129 189 173 135 236 249]; show_graph(g); g1=trans_closure(g); vv=1*ones(ta); aa=sparse([ta' he'],vv'); ta1=g1.edges.tail; he1=g1.edges.head; ww=1*ones(ta1); bb=sparse([ta1' he1'],ww'); dif=bb-aa; lim=size(ta1); edgecolor=0*ones(ta1); for i=1:lim(2) if dif(ta1(i),he1(i))==1 then edgecolor(i)=11; end; end; g1.edges.graphics.foreground=edgecolor; show_graph(g1); | ![]() | ![]() |