consecutive node sequence and pathlength problem using networkx graph
bob
bobtnur78 at gmail.com
Wed Jun 13 19:44:22 EDT 2012
Let say,I have a conjugated cyclic polygon and its nodes are given
by the list:
list_p=[a,b,c,d,e,f,g,a,a,b,d,d,d,d,d,c,c,e,e,a,d,d,g]. If X & Y
are any elements in
a list_p except d, and Z is also an element of list_p but has
value only d, i.e,
Z=d. Now,I want to compute the number of paths with sequence X-Z-
Y consecutive nodes,
example: a-d-d-e,a-d-d-a, a-d-d-d-g, etc. Consecutive path length
of Z can be 1,2,3,4 or 5.
To generalize: Find total number of paths with consecutive X-Z-Y
sequence for path length of
z within range(1,6): or
(i) X-Z-Y for len(Z)=1
(ii) X-Z-Y for len(Z)=2
(iii)X-Z-Y for len(Z)=3
(iv) X-Z-Y for len(Z)=4
(v) X-Z-Y for len(Z)=5
Is there any easy way to program this using python networkx or
igraph?
More information about the Python-list
mailing list