APVVALUE(G)

advertisement
We use graphs to model actors and partnerships we have described thus far. Actors are vertices and
partnership values are weighted arcs relating actors. A path is a sequence of such arcs. Our program
is presented with a matrix that contains several graphs. Our program processes the matrix to
identify graphs in the matrix. This is done with a standard algorithm that discovers connected
components. A set of vertices are a connected component if every vertex can be reached from every
other vertex. We will not further elaborate this algorithm. Interested reader can examine [Corman,
Leiserson, Rivest and Stein, 2002]. Once graphs are identified, we use them as input to our
algorithm we call Maximum MPV (MAPV). MAPV works on each graph separately. Once all
graphs are processed, the results are formatted in the input matrix format. Next, we describe
operations of MAPV on a single graph. MAPV is a polynomial time algorithm that finds the path
and its corresponding APV value among all possible paths that minimizes APV between all pairs of
nodes in a valued graph. A polynomial time algorithm is good news since it indicates
computational tractability. An algorithm is polynomial when the number of times it suggests
processing information is a finite power of its input size.
MAPV considers each vertex v at a time and incrementally constructs a path from that node to all
other vertices, let’s call it i. When considering vertex v, a vertex i is selected such that it has the
minimum APV thus far. That vertex i is marked as visited for paths starting at v. This means that
for vertex v, I is considered as the vertex with ideal APV value and it will not be visited again.
Henceforth, the partial path from v to i is considered for extension in subsequent processing. Every
node j that extends vertex the path from v to i and yields a lower APV than the existing APV for
the path will be used to make the path longer, i.e., augment the path and will be recorded for j to be
the best candidate path along the observed path.
The algorithm continues until all such j nodes are marked as visited for v. At the end of this process
for vertex v, paths that yield smallest APV starting from v along with their APVs are discovered
and recorded. This computation has produced minimum indirect APVs. We then compare the
indirect APV value with the value on direct arcs from v to other vertices and pick the value that is
larger. MAPV then picks up the next vertex for processing and continues this process. The pseudocode is shown in Figure 1 below.
To illustrate, consider the following graph:
6
B
D
10
3
A
F
7
5
C
10
15
9
E
The following table shows the processing for vertex A only.
Vertices
APV
Path
Visited
APV
Path
Visited
APV
Path
Visited
APV
Path
Visited
APV
Path
Visited
APV
Path
Overall APV
A
B
10/1
AB
X
10/1
AB
X
10/1
AB
X
10/1
AB
X
10/1
AB
X
10/1
AB
10/1
C
5/1
AC
D
E
5/1
AC
6/2
ABD
10/3
ABEC
X
10/3
ABEC
X
10/3
ABEC
X
3/5
ABEFDC
5/1
6/2
ABD
10/2
ABE
X
10/2
ABE
X
10/2
125
X
10/2
125
X
10/2
ABE
10/2
7/3
ABECD
¾
ABEFD
X
¾
ABEFD
3/4
F
9/3
ABEF
9/3
ABEF
X
9/3
ABEF
X
9/3
ABEF
9/3
MAPV(G)
1. for each vertex v of G {
1.1 Initialize a path along with distance of 1 and APV value which is the
edge value between v and every directly connected vertex
1.2 for each vertex i of G { /* i is vertices other than v */
1.2.1
Select the next vertex such that it has the highest APV value for
vertex v that is not yet marked as visited. Let’s call this vertex m.
1.2.2
Mark m as visited. Consider the path and APV at m to extend in
the following loop
1.2.3
for each vertex j of G { /* j is not m or v */
1.2.3.1
If the path from v to i can be augmented by an edge to j
yields a smaller APV than the existing APV recorded for node j, append j to
the path and record the new APV value of that path at node j.}}
1.3 for every vertex k in G {
1.3.1
Select the APV that is larger between a direct edge from v to k and
the indirect APV computed this far for k.}}
Figure 1. The MAPV Algorithm
Running time of our algorithm in n3 where n is the input size.
T. Cormen, C. Leiserson, Rivest and C. Stein, 2002. Introduction to Algorithms (Second Edition)
published by MIT Press and McGraw-Hill.
Download