ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/lib/outil/src/HypergraphLib_Components.cpp
Revision: 283
Committed: Tue Sep 13 21:11:20 2011 UTC (13 years, 8 months ago) by francois
File size: 1244 byte(s)
Log Message:
structure de l'écriture

File Contents

# User Rev Content
1 francois 113 #include "gestionversion.h"
2 francois 283 #include "HypergraphLib_platform.h"
3    
4     #include "HypergraphLib_Components.h"
5     #include "HypergraphLib_dfs.h"
6     #include "HypergraphLib_Graph.h"
7     #include "HypergraphLib_Node.h"
8    
9     /**
10     * Find the strongly connected components of a graph
11     // http://en.wikipedia.org/wiki/Strongly_connected_component
12    
13    
14     STRONGLY-CONNECTED COMPONENTS (G)
15     1 call DFS(G) to compute finishing times f[u] for each vertex u
16     2 compute GT
17     3 call DFS(GT), but in the main loop of DFS, consider the vertices in order of decreasing f[u]
18     4 produce as output the vertices of each tree in the DFS forest formed in point 3 as a separate SCC.
19    
20     */
21     namespace HypergraphLib {
22    
23     void FindSCC(Graph * __G, std::set < std::set < Node * > > & __components)
24     {
25     std::map < int, Node * > unvisitedNodes = __G->GetNodes();
26    
27     while (unvisitedNodes.size())
28     {
29     std::set < Node * > depthFirstSearchNodes;
30     dfs((unvisitedNodes.begin())->second, depthFirstSearchNodes);
31     __components.insert ( depthFirstSearchNodes );
32     for ( std::set < Node * >::const_iterator it = depthFirstSearchNodes.begin();
33     it != depthFirstSearchNodes.end();
34     it++)
35     unvisitedNodes.erase((*it)->Id());
36     }
37 francois 102 }
38 foucault 176
39 francois 283 }
40