Logic and discrete mathematics: a computer science perspective
Logic and discrete mathematics: a computer science perspective
Maple V: programming guide
Journal of the ACM (JACM)
Communications of the ACM
Hi-index | 0.00 |
Counting the number of paths in a graph is easily accomplished using powers of the adjacency matrix for the graph, while enumerating these paths is difficult. There appears to be only one technique, Floyd's algorithm [1], whose end result can be used, with a considerable amount of paper and pencil manipulation, to actually list in order the vertices that make up each path. Even so, Floyd's algorithm is used only to find shortest paths. This paper describes a technique in Maple that automatically prints out all paths of any desired length, along with the name of each vertex, proceeding in order from start (beginning vertex) to finish (ending vertex). This is accomplished by defining a new matrix multiplication that produces all paths, with the option of listing only the simple ones; can handle alphanumeric entries; and eliminates the clustering of parentheses and messy output obtained when using ordinary matrix multiplication with alphabetic entries.