[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

530.0. "Node Enumeration" by HOW::TURNER () Fri Jul 04 1986 10:18

I'm looking for a scheme to enumerate the nodes of a finite-state
diagram (a type of directed graph).  I'm pretty rusty at this stuff,
so I'll be glad to accept corrections to my terminology.

Goal
----
   An enumeration algorithm which will:

	. Allow a quick (formulaic) determination of whether any one
	  node is in some succession path from any other node.  I don't
	  care about how many steps away it is, or listing all the paths;
	  a yes/no answer is just fine.

	. Allow for insertion and removal of any number of nodes without 
	  changing the labeling of any existing node.

Constraints
-----------
    The finite-state diagram I'd like to handle has the following properties:

	. One start state (= root).

	. >= 1 terminal states or nodes.

	. >=1 arc can point to any node which is not the root.

	. >=1 arc can leave (point away from) a non-terminal node.

	. The only kind of cycle is where a node points directly back to
	  itself.  No indirect cycles allowed, e.g.

		  OK                            Not OK

               +-------+                      +--B <--+
               |       |                      |       |
               +--> A--+                      +--> A--+
	
	. The longest path in the graph is some reasonable size for computing
	  purposes, e.g. <= the number of bits in a word.

Help in any form appreciated.

				
						Regards,


						Mark 
T.RTitleUserPersonal
Name
DateLines
530.1CLT::GILBERTJuggler of NoterdomFri Jul 04 1986 14:0030
Note that the graph is a DAG (directed acyclic graph), if it weren't for
the edges that connect a node to itself.


Let there be N nodes, and form the NxN matrix A, where A(i,j) = 1
if there is an edge connecting node i to node j, and zero otherwise.

Now, the matrix product AxA = B represents the two-step paths:
B(i,j) is the number of two-step paths from node i to node j.

In general, the elements in the m-th power of the matrix (i.e., A^m)
represent the number of m-step paths from node i to node j.

Thus, A+A^2+A^3+...+A^N gives the total number of paths between nodes.


Usually, the matrix multiplication is done over the field (OR,AND) --
instead of (+,*) -- so that the above formulation would yield boolean
elements that just indicate whether there is such a path.  And the
matrix multiplications and additions can be stopped after it no longer
affects the sum.


Because the algorithm must allow for the insertion and removal of nodes
(and presumably edges), an alternative approach is warranted.  The problem
is roughly equivalent to a topological sort.  If the determination of
whether one node follows another need not be very fast, a depth-first
search (over the graph) could be used.

Other ideas, anyone?
530.2CLT::GILBERTJuggler of NoterdomFri Jul 04 1986 14:021
Also, does the algorithm itself need to verify the acyclic constraint?
530.3Acyclic ConstraintWHY::TURNERSat Jul 05 1986 22:476
    re: .2: No; let's assume that the constraint needn't be verified.
    
    Thanks for the ideas so far.
    
    
    						Mark
530.4counting the pathsGALLO::JMUNZERMon Jul 07 1986 18:1635
It seems to me that it's feasible to count all possible paths.  Keep
track of

		n(X,Y) = number of paths from node X to node Y

for all nodes X and Y.
    
If a node N is added, create n(Q,N) and n(N,Q) for all existing nodes Q,
and set them all to zero.  Then,

	whenever the paths in this diagram exist:

	W -------> X -------> N -------> Y -------> Z
           n(W,X)     n(X,N)     n(N,Y)     n(Y,Z)

		set n(X,N) = 1
		set n(N,Y) = 1
		increase n(W,N) by n(W,X)
		increase n(N,Z) by n(Y,Z)
		increase n(W,Y) by n(W,X)
		increase n(X,Z) by n(Y,Z)
		increase n(W,Z) by n(W,X)*n(Y,Z)

Deletion of node N:  reverse the increases, and throw away all n(X,N)'s
and n(N,Y)'s.

Possible implementation:  for each node N, keep lists of:

	all the nodes X for which n(X,N) > 0, and all the values n(X,N)
	all the nodes Y for which n(N,Y) > 0, and all the values n(N,Y)

John

[ Note the similarity of "increase n(W,Z) by n(W,X)*n(Y,Z)" to matrix
  multiplication (see 530.1). ]
530.5For those still tuned in...FASDER::MTURNERMark Turner * DTN 425-3702 * MEL4Tue May 07 1991 11:4417
    [for those still following this after the small hiatus...]
    
    re: .4 - 	Haven't tried this, but it looks as though it has an
    		advantage in space, if not time, over matrix
    		multiplication.
    
    re: .1 - 	Assuming that we'd wish to stop the multiplication
    		(using (OR, AND)) as quickly as possible, are there
    		any *quick* algorithms that can tell:
    
    
    			. whether two boolean matrices are identical,
    			  i.e. does A^n = A^(n+1), or
    
    			. whether the next multiplication won't change
    			  the matrix, i.e. given A^n, can we tell quickly
    			  whether A^(n+1) will equal A^n?