circuit — finds a circuit or the rank function in a directed graph
[p,r] = circuit(g)
row vector of integer numbers of the arcs of the circuit if it exists
row vector of rank function if there is no circuit
A cycle of a graph g
, also called a
circuit, is a subset of the edges of g
that forms
a path such that the first node of the path corresponds to the
last.
circuit
tries to find surch a circuit
for the directed graph g
. It returns the circuit
p
as a row vector of the corresponding arc numbers if
it exists and it returns the empty vector []
otherwise.
If the graph has no circuit, the rank function is returned in r
,
otherwise its value is the empty vector []
.
// graph with circuit ta=[1 1 2 3 5 4 6 7 7 3 3 8 8 5]; he=[2 3 5 4 6 6 7 4 3 2 8 1 7 4]; g=make_graph('foo',1,8,ta,he); g.nodes.graphics.x=[116 231 192 323 354 454 305 155]; g.nodes.graphics.y=[ 118 116 212 219 117 185 334 316]; g.nodes.graphics.display='number'; g.edges.graphics.display='number'; show_graph(g); p=circuit(g) hilite_edges(p) // graph without circuit g1=make_graph('foo',1,4,[1 2 2 3],[2 3 4 4]); g1.nodes.graphics.x=[116 231 192 323]; g1.nodes.graphics.y=[ 118 116 212 219]; g1.nodes.graphics.display='number'; g1.edges.graphics.display='number'; show_graph(g1,'new'); [p,r]=circuit(g)