Network::longPath -- longest
paths from one single node
Introduction finds the longest
path in network Network::longPath(G, v)G starting from
vertex v.
Call(s)Network::longPath(G, v <, w> <, Length> <, Path>)
ParametersG |
- | a network |
v,w |
- | nodes in G |
OptionsLength |
- | Return a table with the lengths of shortest paths |
Path |
- | Return a table with the paths themselves |
Returnsa table, an integer or a list of nodes
DetailsNetwork::longPath(G, v) returns a table
with the length of longest paths from v to all other nodes
in the network with respect to the edge weight.Network::longPath(G, v, w) returns the
length of a longest path from v to w.G should not contain cycles.
Example
1We construct a network and try a few calls to
Network::longPath:
>> V := [1,2,3,4,5]: Ed := [[1,2], [1,3], [2,3], [2,4], [3,4], [3,5], [4,5]]: Ew := [7, 6, 5, 4, 2, 2, 1]: N1 := Network(V, Ed, Eweight=Ew): Network::longPath(N1,1)
table(
5 = 15,
4 = 14,
3 = 12,
2 = 7,
1 = 0
)
>> Network::longPath(N1,1,Path)
table(
5 = [2, 1, 2, 3, 4],
4 = [2, 1, 2, 3],
3 = [2, 1, 2],
2 = [2, 1]
)
BackgroundNetwork::LongPath