mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
191 lines
5.3 KiB
Plaintext
Executable File
191 lines
5.3 KiB
Plaintext
Executable File
// Created on: 1993-03-16
|
|
// Created by: Denis PASCAL
|
|
// Copyright (c) 1993-1999 Matra Datavision
|
|
// Copyright (c) 1999-2012 OPEN CASCADE SAS
|
|
//
|
|
// The content of this file is subject to the Open CASCADE Technology Public
|
|
// License Version 6.5 (the "License"). You may not use the content of this file
|
|
// except in compliance with the License. Please obtain a copy of the License
|
|
// at http://www.opencascade.org and read it completely before using this file.
|
|
//
|
|
// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
|
|
// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
|
|
//
|
|
// The Original Code and all software distributed under the License is
|
|
// distributed on an "AS IS" basis, without warranty of any kind, and the
|
|
// Initial Developer hereby disclaims all such warranties, including without
|
|
// limitation, any warranties of merchantability, fitness for a particular
|
|
// purpose or non-infringement. Please see the License for the specific terms
|
|
// and conditions governing the rights and limitations under the License.
|
|
|
|
|
|
#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);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|