250 likes | 277 Views
Chapter 2 Paths, Trees, and Cycles. 1.2 Notation and Definitions. Directed Graphs and Networks: G = (N, A), A: set of ordered pair of distinct nodes Undirected Graphs and Networks: G = (N, A) ( G = (V, E) ), A: set of unordered pair of distinct nodes Tails and Heads:
E N D
1.2 Notation and Definitions • Directed Graphs and Networks: G = (N, A), A: set of ordered pair of distinct nodes • Undirected Graphs and Networks: G = (N, A) ( G = (V, E) ), A: set of unordered pair of distinct nodes • Tails and Heads: directed arc (i, j) : i is the tail and j is the head of arc (i, j) • Degrees: indegree of node i: number of incoming arcs of that node outdegree of node i: number of outgoing arcs of that node degree of node i: sum of the indegree and outdegree of node I
Adjacency List: arc adjacency list A(i) of a node i: set of arcs emanating from that node, A(i) = {(i, j)A: jN} node adjacency list A(i) of a node i: set of nodes adjacent to that node, A(i) = { jN: (i, j)A} Property 2.1 iN |A(i)| = m. • Multiarcs and Loops: multiarcs: two or more arcs with the same tail and head nodes. loop: arc whose tail node is the same as its head node. (in most cases, no multiarcs or loops)
Subgraph: G’ = (N’, A’) is a subgraph of G = (N, A) of N’N, A’A. G’ = (N’, A’) is a subgraph of G induced by N’ if A’ contains each arc of A with both ends in N’ (induced subgraph) spanning subgraph if N’ = N, A’A. • Walk: subgraph of G consisting of a sequence of nodes and arcs i1 – a1 – i2 – a2 - … - ir-1 – ar-1 – ir satisfying ak = (ik, ik+1)A or (ik+1, ik)A, for 1 k r-1. (node, arc repetition allowed) directed walk: oriented version of a walk, (ik, ik+1)A ( trail: walk without arc repetition) • Path: walk without any repetition of nodes (and arcs) (elementary path) • Forward arcs, backward arcs directed path: directed walk without any repetition of nodes. ( can store a path using predecessor index pred(j) for every j in the path.
Cycle: path with i1 = ir+1 Directed cycle: directed path with arc (ir, i1) • Acyclic network: contains no directed cycle (for undirected network, contains no cycle. Forest) • Connectivity: nodes i, j connected if there exists a path from i to j. A graph is connected if every pair of its nodes are connected. Otherwise, disconnected components: maximal connected subgraphs of a disconnected graph • Strongly connected if the graph contains at least one directed path from every node to every other node.
Cut: A cut is a set of arcs (i, j)A such that iS, jS or jS, iS, SN. A cut is represented by [S, S]. ( S = N-S ) (sometimes we consider directed case, iS, jS) • s-t cut: a cut with node sS, tS • Tree: connected graph that contains no cycle (compare with forest) • Property 2.2 • A tree on n nodes contains exactly n-1 arcs • Has at least two leaf nodes (node with degree 1) • There exists a unique path between any two nodes • Forest: A graph that contains no cycle (compare with tree)
Subtree: connected subgraph of a tree • Rooted tree: a tree with a specially designated node, called root. predecessor-successor (or parent-child) relationships descendants, ancestor • Directed out-tree rooted at node s: the unique path from node s to every other node is a directed path. (also called arborescence) • Directed in-tree rooted at node s: the unique path from any node to node s is a directed path. • Spanning tree: A tree T is a spanning tree of G if T is a spanning subgraph of G.
Fundamental cycles: adding an arc to a tree T creates a unique cycle (fundamental cycle). Deleting an arc in a fundamental cycle makes a spanning tree. • Fundamental cuts: deleting an arc in a tree T creates two subtrees T1 and T2. Arcs whose endpoints belong to the different subtrees constitute a cut (fundamental cut of G with respect to the tree T). • Bipartite graph: G = (N, A) such that we can partition the nodes into two sets N1 and N2 so that for each arc (i, j) in A either (i) iN1, jN2, or (ii) iN2, jN1. • Property 2.3: G is a bipartite graph if and only if every cycle in G contains an even number of arcs (even cycle). • Definitions for undirected graph similar to the directed graph.
2.3 Network Representations • Performance of the algorithms on networks critically affected by the data structures used and operations on intermediate results. • Node-Arc Incidence Matrix: coefficient matrix of the MCF formulation For arc (i, j) (variable xij), corresponding column has one +1 for i-th position, one -1 for j-th position, and 0 elsewhere. (use two, +1’s for undirected graph) • Node-Node Adjacency Matrix: Hij =1, if (i, j)A • Symmetric for undirected graph, then maintain only upper triangular part • Appropriate for dense graph
Adjacency lists: arc, node adjacency list, use linked list (cij, uij) i j (15, 40) 2 4 1 2 3 4 5 (25, 30) (45, 10) (15, 30) (35, 50) 1 (45, 60) (35, 50) 3 5 (25, 20) Adjacency List
Sometimes need to consider the case (i, j)A (j, i)A. Then maintain additional field for pointer mate ( (i, j) (j, i) ) • Adjacency list is compact. Can add, delete arcs easily. The programming language needs to support pointers.
Forward and Reverse Star Representations: • Forward Star • Store the arcs in a single array instead of linked list • Assign unique sequence number to each arc • Start with arcs emanating from node 1, then node 2, … • Arcs emanating from the same node are numbered in an arbitrary fashion. • For each node i, maintain point(i) to point the index of the first outgoing arc from node i. • If no outgoing arc, set point(i) = point(i+1). • Reverse star stores incoming arcs.
point Tail head cost capacity 1 2 3 4 5 6 7 8 1 2 3 4 5 6 (cij, uij) i j (15, 40) 2 4 (25, 30) (45, 10) (15, 30) (35, 50) 1 (45, 60) (35, 50) 3 5 (25, 20) Forward Star Representation
cost capacity tail head rpoint 1 2 3 4 5 6 7 8 1 2 3 4 5 6 (cij, uij) i j (15, 40) 2 4 (25, 30) (45, 10) (15, 30) (35, 50) 1 (45, 60) (35, 50) 3 5 (25, 20) Reverse Star Representation
point Tail head cost capacity trace rpoint 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 1 2 3 4 5 6 Compact forward and reverse star
2.4 Network Transformations • Undirected Arcs to Directed Arcs : cij 0, lij = 0 case undirected case has constraints xij +xji uij. One of xij, xji is 0 in an optimal solution (cij, uij) (cij, uij) i j i j (cij, uij)
Removing Nonzero Lower Bounds: nonzero lower bound lij replace xij by x’ij + lij lij x’ij + lij uij 0 x’ij uij - lij In the mass balance eq., results in decresing b(i) by lij and increasing b(j) by lij. b(j) b(i) b(j) + lij b(i) - lij (lij, uij) (0, uij – lij ) i j i j xij x'ij = xij - lij
Arc Reversal (removing negative costs): Let uij be the capacity of upper bound if uncapacitated. Replace xij by uij – xji ( (First send uij units of flow on (i, j), then use arc (j, i) with cost –cij. The flow xji measures the amount of flow we ‘remove’ from the ‘full capacity’ flow of uij ) b(j) b(i) b(j) + uij b(i) - uij (cij, uij) (-cij , uij ) i j i j xij xji
Removing Arc Capacities: Introduce an additional node so that the capacity constraint on arc (i, j) becomes the mass balance constraint of the new node. Use slack variable: xij + sij = uij -xij - sij = -uij (2.2) Use (2.2) as the mass balance constraint of an additional node k. 3 appearances of xij , 1 appearance of sij subtract (2.2) from the mass balance constraint of node j (solutions not changed). b(j) b(i) b(j)+uij - uij b(i) (cij, uij) (cij, ) (0, ) i j j i k xij xij sij
Node Splitting (when nodes have capacities and costs): • If b(i) > 0, then b(i’’) = b(i) and b(i’) = 0 • If b(i) < 0, then b(i’’) = 0 and b(i’) = b(i) • If b(i) = 0, then b(i’) = b(i’’) = 0 • When node i incurs cost ci and capacity ui set ci, ui as cost and capacity of arc (i’’, i’). b(j) b(i) (cij, uij) i' j' i j (cij, uij) (0, ) (0, ) b(j) b(i) i’’ j’’
Working with Reduced Costs: frequently use node potential (i) for node i to modify cost cij reduced cost cij of arc (i, j) defined as cij = cij - (i) + (j) define z() = (i, j)A cij xij • Recall reduced cost for variable xj in LP : cj – y’Aj, where Aj is j-th column of A and y is vector of dual variables. For MCF, the reduced cost for variable xij is cij – yi + yj . • at node k: outflow cost change is - (k) outflow inflow cost change is + (k) inflow total cost change: - (k) (outflow – inflow) = - (k) b(k) For all nodes, cost change is - b. Hence z() = z(0) - b, or z(0) – z() = b, which is a constant. A flow which minimizes z() also minimizes z(0) and conversely.
Property 2.4. MCF with cij or cij have the same optimal solutions. Moreover, z() = z(0) - b. • Reduced cost along a directed cycle and a path Let W be a directed cycle in G. Then (i, j)W cij= (i, j)W (cij - (i) + (j)) = (i, j)W cij + (i, j)W ((j) - (i)) = (i, j)W cij. Let P be a directed path from node k to node l. Then (i, j)P cij= (i, j)P (cij - (i) + (j)) = (i, j)P cij - (i, j)P ((i) - (j)) = (i, j)W cij - (k) + (l).
Working with Residual Networks: In network flow algorithms, frequently use incremental flow about some given feasible flow x0 residual network (cij, uij) (cij , uij – x0ij) i j i j x0ij (-cij , x0ij) • If both (i, j) and (j, i) exist, have parallel arcs in residual network. • For notational convenience, assume G has (i, j) or (j, i), but not both. (can use transformation to make any graph satisfy this property.) • In practice, network representation can handle parallel arcs. • For max flow problem, costs are 0, hence can merge parallel arcs as one arc.
For every feasible flow x in G, define flow x’ in the residual network G(x0). x’ij – x’ji = xij – x0ij , x’ij x’ji = 0 • If xij x0ij , we set x’ij = (xij – x0ij) and x’ji = 0. If xij< x0ij , we set x’ij = 0 and x’ji = (x0ij – xij ). • The cost of flow on arc (i, j) in G(x0) is c’ij x’ij + c’ji x’ji = c’ij(x’ij – x’ji) = cijxij – cijx0ij c’x’ = cx – cx0.
Note that for MCF problem, the flow in G(x0) is a circulation. Let x and x0 be feasible flows for MCF. Then xij = (xij’ – xji’) + xij0. x and x0 satisfy (outflow for x) – (inflow for x) = b(i) for all iN. (outflow for x0) – (inflow for x0) = b(i) for all iN. Subtracting both sides, get (outflow for x-x0) - (inflow for x-x0) = 0 From xij - xij0 = (xij’ – xji’), (out – in for (xij - xij0)) = (out – in for (xij’ – xji’)) = 0 for each node i. Hence the flow in G(x0) is a circulation.