Network::new
-- generates a new
networkNetwork(V, E)
is used to generate a new
Network
with vertices V
and edges
E
, which can be manipulated using the functions in the
Network
library.
Network::new(V, E)
Network::new(V, E <, Eweight=lc>
<, Capacity=lt> <, Vweight=lv>)
V |
- | list of expressions (nodes) |
E |
- | list of edges |
Eweight=lc |
- | The weights of the edges, given as a list of numbers |
Capacity=lt |
- | The capacity of the edges, given as a list of numbers |
Vweight=lv |
- | The weights of the vertices, given as a list of numbers |
A Network
Network::new
(V, E)
generates a new
network. A network consists of a list of nodes and a list of edges
connecting the nodes. These lists must be specified for the definition
of a new network. If one of them is missing an error occurs.Network::new
(args)
the short form
Network(args)
can be used. The examples in the
description below use this short form.Network(V,E)
where V
is a list of nodes
and E
a list of edges generates a new network with exactly
this set of nodes and edges respectively. A node in a network can be an
arbitrary expression. An edge is a list, which contains the start point
and the endpoint of the edge. Therefor, if there are edges specified
for which the incident nodes are not contained in the list
V
an error occurs.Network(V, E, Eweight=lc, Capacity=lt, Vweight=lv)
. Here lc
, lt
and lv
are numerical lists with exactly as many items as
E
and V
respectively. For example, the
capacity lt[i]
is assigned to edge E[i]
. If
these specifications are missing, the default values 1
for
edge weight and capacity and 0
for vertex weight are
assumed.>> V := [1,2,3,q,s]: Edge := [[q,1], [1,2], [1,3], [2,3], [3,s]]: up := [5, 4, 4, 2, 5]: N1 := Network(V,Edge,Capacity=up): Network::printGraph(N1);
Vertices: [1, 2, 3, q, s] Edges: [[q, 1], [1, 2], [1, 3], [2, 3], [3, s]] Vertex weights: table(s=0,q=0,3=0,2=0,1=0) Edge capacities: table([3, s]=5,[2, 3]=2,[1, 3]=4,[1, 2]=4,[q,\ 1]=5) Edge weights: table([3, s]=1,[2, 3]=1,[1, 3]=1,[1, 2]=1,[q, 1]\ =1) Adjacency list (out): table(s=[],q=[1],3=[s],2=[3],1=[2, 3]) Adjacency list (in): table(s=[3],q=[],3=[1, 2],2=[1],1=[q])
>> V := [1,2,3,4,5]: Vw := [25,0,0,0,-25]: Ed := [[1,2], [1,3], [2,3], [2,4], [3,4], [3,5], [4,5]]: Ew := [7, 6, 5, 4, 2, 2, 1]: Ecap := [30, 20, 25, 10, 20, 25, 20]: N2 := Network(V,Ed,Eweight=Ew, Capacity=Ecap, Vweight=Vw): Network::printGraph(N2)
Vertices: [1, 2, 3, 4, 5] Edges: [[1, 2], [1, 3], [2, 3], [2, 4], [3, 4], [3, 5], [4, 5]] Vertex weights: table(5=-25,4=0,3=0,2=0,1=25) Edge capacities: table([4, 5]=20,[3, 5]=25,[3, 4]=20,[2, 4]=10\ ,[2, 3]=25,[1, 3]=20,[1, 2]=30) Edge weights: table([4, 5]=1,[3, 5]=2,[3, 4]=2,[2, 4]=4,[2, 3]\ =5,[1, 3]=6,[1, 2]=7) Adjacency list (out): table(5=[],4=[5],3=[4, 5],2=[3, 4],1=[2,\ 3]) Adjacency list (in): table(5=[3, 4],4=[2, 3],3=[1, 2],2=[1],1=\ [])