forked from Smorodov/Multitarget-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponents.cpp
More file actions
70 lines (53 loc) · 1.65 KB
/
components.cpp
File metadata and controls
70 lines (53 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* This software is distributed under the GNU Lesser General Public License */
//==========================================================================
//
// components.cpp
//
//==========================================================================
// $Id: components.cpp,v 1.5 2001/11/07 13:58:09 pick Exp $
#include <GTL/components.h>
__GTL_BEGIN_NAMESPACE
components::components () : dfs ()
{
scan_whole_graph (true);
num_of_components = 0;
}
void components::reset ()
{
dfs::reset ();
comp.erase (comp.begin(), comp.end());
num_of_components = 0;
}
int components::check (graph& G)
{
return G.is_undirected() && whole_graph &&
dfs::check (G) == GTL_OK ? GTL_OK : GTL_ERROR;
}
//--------------------------------------------------------------------------
// Handler
//--------------------------------------------------------------------------
void components::new_start_handler (graph& /*G*/, node& st)
{
li = comp.insert(comp.end(), std::pair<nodes_t, edges_t>(nodes_t(), edges_t()));
li->first.push_back(st);
++num_of_components;
}
void components::before_recursive_call_handler (graph& /*G*/, edge& /*e*/, node& n)
{
li->first.push_back(n);
// li->second.push_back(e);
}
void components::old_adj_node_handler (graph& /*G*/, edge& e, node& n)
{
node curr = n.opposite (e);
//
// Store backedges at lower endpoint
//
if (dfs_num (curr) > dfs_num (n)) {
li->second.push_back (e);
}
}
__GTL_END_NAMESPACE
//--------------------------------------------------------------------------
// end of file
//--------------------------------------------------------------------------