This note describes a generalization of an algorithm given by Aho, Hopcroft, and Ullman , originally derived from the work of Kleene  and McNaughton and Yamada . The algorithm is used to compute the total cost of all paths between each pair of vertices in a directed graph when the cost of each edge is known. The cost of a path is defined as the product of the costs of the edges forming it, and the total cost of a set of paths is the sum of their individual costs. If there are n vertices labeled 1 through n and E[i, j] is the cost of the edge from vertex i to vertex j (or is zero when there is no such edge), then the total cost T[i, j] of all paths from i to j is the solution of the equation T[i, j] = &dgr;[i, j] + ∑nk-1 E[i, k]·T[k, j], (1) where &dgr;[i, i] = 1 (the cost of the path of no edges from i to i) and &dgr;[i, j] = 0 if i ≠ j. To assure that T [i, j] is always well-defined, costs are required to be elements from an algebraic structure called a closed semiring.
The full text of this article is premium content
No entries found
Log in to Read the Full Article
Please select one of the options below for access to premium content and features.
Create a Web Account
If you are already an ACM member, Communications subscriber, or Digital Library subscriber, please set up a web account to access premium content on this site.
Join the ACM
Become a member to take full advantage of ACM's outstanding computing information resources, networking opportunities, and other benefits.
Subscribe to Communications of the ACM Magazine
Get full access to 50+ years of CACM content and receive the print version of the magazine monthly.
Purchase the Article
Non-members can purchase this article or a copy of the magazine in which it appears.