views:

223

answers:

1

I'm trying to partition a network into one or more parts based on a set of critical vertices. I've got code that I believe solves my problem (at least, it has for the cases I'm interested in), but for the sake of ensuring correctness in general, I'm looking for the name of what I'm doing from graph theory, or even a reference on an equivalent algorithm or process.

The input network is a directed graph with a single source and sink vertex. The resultant partitions must have the same property as the original (directed graphs, single source vertex, single sink vertex), with the additional requirement that each partition should only have two vertices that are in the critical set, and they must be the initial and terminal vertices.

Edit

If the source and sink are the same vertex, the resultant sub-graph would contain a cycle. Existing code is available to detect and remove such cycles. .

End Edit

In this case a diagram is worth 1000 words, I've drawn up a simple graph, the colored vertices represent the critical vertices, and the dotted lines are the partitions of the graph.

alt text

In this case, the intention is to find any possible partitions between 1-1, 1-3, 1-7, 3-1, 3-3, 3-7, 7-1, 7-3 or 7-7. Only the partitions 1-3, 3-3 and 3-7 actually exist (see image below). Additionally, because the 3-3 partition is invalid, the graph has been relabeled to remove the inconsistancy.

alt text

If it helps, my python-eque psuedocode works by performing a series of forward and backward graph traversals to identify all of the possible partitions.

def graphTraversal(graph,srcid,endids):
    '''
    Given a graph, start a traversal from srcid, stopping search 
    along a branch any time a vertex is in endids.

    Return the visited subgraph 
    '''
    closed = set()
    open = set([srcid])
    while len(open) != 0:
        i = open.pop()
        for j in graph.succ(i):
            if (i,j) not in closed:
                if j not in endids:
                    open.add(j)
                closed.add( (i,j) )
    return = graphFromList(closed)

def findAllValidPartitions(graph,srcids):
    res = []
    for n in srcids:
        g2    = graphTraversal(graph,n,t)
        g2rev = reverseEdgesInGraph(g2)
        for s in srcids:
            g3    = graphTraversal(g2rev ,s,t)
            g3rev = reverseEdgesInGraph(g3)
            g3rev = removeCycles(g3rev,s)
            if len(g3rev .E) > 0:
                res.append(g3rev)
    return res
+1  A: 

I think you're trying to find cuts between connected components.

Dmitry
It's almost like that, but the sub-graphs have some overlap
Andrew Walker
Yes, I read it wrong. What is "critical" vertex then? Your drawing looks like you are trying to find a minimal cut (and max flow through the network)
Dmitry
The entire graph has been used for max-cut min-flow, but I'm looking to break the big graph down into smaller pieces. The paths between critical vertices represent localised maximum flows.
Andrew Walker
Are you sure that partitions have the same properties as the whole graph? For instance, a green partition on your drawing has no source and no sink (it is a cycle).
Dmitry
Unfortunately, such cycles can, and do occur frequently. They are however easy to detect, and it's possible to remove them by performing a relabeling of the graph which encodes all of the same information.
Andrew Walker
So why it is "3" which is "critical", not "2"? They seem to be equivalent with respect to flows. I still don't understand the definition of "critical" vertex
Dmitry
Sorry, the set of critical vertices includes the initial and terminal nodes of the original graph, and other vertices which are selected by an external process. Whether a vertex 'v' is critical if indegree(v)==0 or outdegree(v) == 0 or v.propertymap['critical'] == True
Andrew Walker
So "critical" has nothing to do with the graph structure? Ok. Green partition is suspicious anyway, as it contains just one critical vertex, while you said that a partition "should only have two critical vertices". Did you mean "not more than two"?
Dmitry
No, only two is essential. I've tried to clarify by showing the final graphs, and the correction related to how cycles are dealt with.
Andrew Walker