blob: c247472af3e8bcdb947127dd17c62292977ab687 (
plain)
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
|
#include <IFGraph_Articulations.ixx>
#include <Interface_InterfaceModel.hxx>
// Points d'Articulation d'un Graphe : ce sont les "passages obliges" du graphe
// Algorithme tire du Sedgewick, p 392
IFGraph_Articulations::IFGraph_Articulations
(const Interface_Graph& agraph, const Standard_Boolean whole)
: thegraph (agraph)
{ if (whole) thegraph.GetFromModel(); }
void IFGraph_Articulations::GetFromEntity
(const Handle(Standard_Transient)& ent)
{ thegraph.GetFromEntity(ent,Standard_True); }
void IFGraph_Articulations::GetFromIter(const Interface_EntityIterator& iter)
{ thegraph.GetFromIter(iter,0); }
void IFGraph_Articulations::ResetData ()
{ Reset(); thegraph.Reset(); thelist = new TColStd_HSequenceOfInteger(); }
void IFGraph_Articulations::Evaluate ()
{
// Algorithme, cf Sedgewick "Algorithms", p 392
thelist = new TColStd_HSequenceOfInteger();
// Utilisation de Visit
Standard_Integer nb = thegraph.Size();
for (Standard_Integer i = 1; i <= nb; i ++) {
thenow = 0;
if (thegraph.IsPresent(i)) Visit(i);
}
// Resultat dans thelist
Reset();
Standard_Integer nbres = thelist->Length();
for (Standard_Integer ires = 1; ires <= nbres; ires ++) {
Standard_Integer num = thelist->Value(ires);
GetOneItem(thegraph.Model()->Value(num));
}
}
Standard_Integer IFGraph_Articulations::Visit (const Standard_Integer num)
{
thenow ++;
thegraph.SetStatus(num,thenow);
Standard_Integer min = thenow;
for (Interface_EntityIterator iter = thegraph.Shareds(thegraph.Entity(num));
iter.More(); iter.Next()) {
Handle(Standard_Transient) ent = iter.Value();
Standard_Integer nument = thegraph.EntityNumber(ent);
if (!thegraph.IsPresent(num)) {
thegraph.GetFromEntity(ent,Standard_False);
nument = thegraph.EntityNumber(ent);
}
Standard_Integer statent = thegraph.Status(nument); // pas reevalue
if (statent == 0) {
Standard_Integer mm = Visit(nument);
if (mm < min) min = mm;
if (mm > thegraph.Status(num)) thelist->Append(num); // ON EN A UN : num
}
else if (statent < min) min = statent;
}
return min;
}
|