ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/REPOS_ERICCA/magic/addin/outil/src/hypergraphlib_components.cpp
Revision: 1156
Committed: Thu Jun 13 22:02:48 2024 UTC (14 months, 2 weeks ago) by francois
File size: 2305 byte(s)
Log Message:
compatibilité Ubuntu 22.04
Suppression des refeences à Windows
Ajout d'une banière

File Contents

# Content
1 //####//------------------------------------------------------------
2 //####//------------------------------------------------------------
3 //####// MAGiC
4 //####// Jean Christophe Cuilliere et Vincent FRANCOIS
5 //####// Departement de Genie Mecanique - UQTR
6 //####//------------------------------------------------------------
7 //####// MAGIC est un projet de recherche de l equipe ERICCA
8 //####// du departement de genie mecanique de l Universite du Quebec a Trois Rivieres
9 //####// http://www.uqtr.ca/ericca
10 //####// http://www.uqtr.ca/
11 //####//------------------------------------------------------------
12 //####//------------------------------------------------------------
13 //####//
14 //####// hypergraphlib_components.cpp
15 //####//
16 //####//------------------------------------------------------------
17 //####//------------------------------------------------------------
18 //####// COPYRIGHT 2000-2024
19 //####// jeu 13 jun 2024 11:54:00 EDT
20 //####//------------------------------------------------------------
21 //####//------------------------------------------------------------
22 #include "hypergraphlib_platform.h"
23
24 #include "hypergraphlib_components.h"
25 #include "hypergraphlib_dfs.h"
26 #include "hypergraphlib_graph.h"
27 #include "hypergraphlib_node.h"
28
29 /**
30 * Find the strongly connected components of a graph
31 // http://en.wikipedia.org/wiki/Strongly_connected_component
32
33
34 STRONGLY-CONNECTED COMPONENTS (G)
35 1 call DFS(G) to compute finishing times f[u] for each vertex u
36 2 compute GT
37 3 call DFS(GT), but in the main loop of DFS, consider the vertices in order of decreasing f[u]
38 4 produce as output the vertices of each tree in the DFS forest formed in point 3 as a separate SCC.
39
40 */
41 namespace HypergraphLib {
42
43 void FindSCC(Graph * __G, std::set < std::set < Node * > > & __components)
44 {
45 std::map < int, Node * > unvisitedNodes = __G->GetNodes();
46
47 while (unvisitedNodes.size())
48 {
49 std::set < Node * > depthFirstSearchNodes;
50 dfs((unvisitedNodes.begin())->second, depthFirstSearchNodes);
51 __components.insert ( depthFirstSearchNodes );
52 for ( std::set < Node * >::const_iterator it = depthFirstSearchNodes.begin();
53 it != depthFirstSearchNodes.end();
54 it++)
55 unvisitedNodes.erase((*it)->Id());
56 }
57 }
58
59 }
60