mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-07-07 01:42:15 +08:00
175 lines
4.4 KiB
Plaintext
Executable File
175 lines
4.4 KiB
Plaintext
Executable File
// File: GraphDS_DirectedGraph.gxx
|
|
// Created: Tue Mar 16 14:12:08 1993
|
|
// Author: Denis PASCAL
|
|
// <dp@bravox>
|
|
|
|
#include <Standard_NoSuchObject.hxx>
|
|
#include <Standard_DomainError.hxx>
|
|
|
|
|
|
//=======================================================================
|
|
//function : GraphDS_DirectedGraph
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
GraphDS_DirectedGraph::GraphDS_DirectedGraph ()
|
|
{
|
|
}
|
|
|
|
|
|
//=======================================================================
|
|
//function : NbVertices
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
Standard_Integer GraphDS_DirectedGraph::NbVertices () const
|
|
{
|
|
return myVertices.Extent();
|
|
}
|
|
|
|
|
|
//=======================================================================
|
|
//function : NbEdges
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
Standard_Integer GraphDS_DirectedGraph::NbEdges () const
|
|
{
|
|
return myEdges.Extent();
|
|
}
|
|
|
|
|
|
//=======================================================================
|
|
//function : IsEmpty
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
Standard_Boolean GraphDS_DirectedGraph::IsEmpty () const
|
|
{
|
|
return (myVertices.IsEmpty());
|
|
}
|
|
|
|
|
|
//=======================================================================
|
|
//function : Clear
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
void GraphDS_DirectedGraph::Clear ()
|
|
{
|
|
myVertices.Clear();
|
|
myEdges.Clear();
|
|
|
|
}
|
|
|
|
|
|
//=======================================================================
|
|
//function : Contains
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
Standard_Boolean GraphDS_DirectedGraph::Contains
|
|
(const Handle(GraphDS_Vertex)& V) const
|
|
{
|
|
return myVertices.Contains(V);
|
|
}
|
|
|
|
//=======================================================================
|
|
//function : IsRoot
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
Standard_Boolean GraphDS_DirectedGraph::IsRoot
|
|
(const Handle(GraphDS_Vertex)& V,
|
|
const Standard_Boolean ignoreselfloop) const
|
|
{
|
|
return V->IsRoot(ignoreselfloop);
|
|
}
|
|
|
|
//=======================================================================
|
|
//function : IsLeaf
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
Standard_Boolean GraphDS_DirectedGraph::IsLeaf
|
|
(const Handle(GraphDS_Vertex)& V,
|
|
const Standard_Boolean ignoreselfloop) const
|
|
{
|
|
return V->IsLeaf(ignoreselfloop);
|
|
}
|
|
|
|
//=======================================================================
|
|
//function : Contains
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
Standard_Boolean GraphDS_DirectedGraph::Contains
|
|
(const Handle(GraphDS_Edge)& E) const
|
|
{
|
|
return myEdges.Contains(E);
|
|
}
|
|
|
|
|
|
//=======================================================================
|
|
//function : Add
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
Handle(GraphDS_Vertex) GraphDS_DirectedGraph::Add
|
|
(const GraphDS_Item& value)
|
|
{
|
|
Handle(GraphDS_Vertex) V = new GraphDS_Vertex (value);
|
|
myVertices.Add(V);
|
|
return V;
|
|
}
|
|
|
|
|
|
//=======================================================================
|
|
//function : Remove
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
void GraphDS_DirectedGraph::Remove (const Handle(GraphDS_Vertex)& V)
|
|
{
|
|
if (!V->GetEdges().IsEmpty()) Standard_DomainError::Raise();
|
|
myVertices.Remove(V);
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
//function : Add
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
Handle(GraphDS_Edge) GraphDS_DirectedGraph::Add
|
|
(const Handle(GraphDS_Vertex)& source,
|
|
const Handle(GraphDS_Vertex)& destination,
|
|
const GraphDS_Attribute& A)
|
|
{
|
|
Handle(GraphDS_Edge) E = new GraphDS_Edge (source,destination,A);
|
|
source->AddEdge (E);
|
|
destination->AddEdge(E);
|
|
myEdges.Add(E);
|
|
return E;
|
|
}
|
|
|
|
|
|
//=======================================================================
|
|
//function : Remove
|
|
//purpose :
|
|
//=======================================================================
|
|
|
|
void GraphDS_DirectedGraph::Remove (const Handle(GraphDS_Edge)& E)
|
|
{
|
|
E->Source()->RemoveEdge(E);
|
|
E->Destination()->RemoveEdge(E);
|
|
myEdges.Remove(E);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|