1 /*---------------------------------------------------------------------------*\
2 * OpenSG NURBS Library *
5 * Copyright (C) 2001-2006 by the University of Bonn, Computer Graphics Group*
7 * http://cg.cs.uni-bonn.de/ *
9 * contact: edhellon@cs.uni-bonn.de, guthe@cs.uni-bonn.de, rk@cs.uni-bonn.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
38 #ifndef _OSG_DIRECTEDGRAPH_H_
39 #define _OSG_DIRECTEDGRAPH_H_
44 #include "OSGDrawableDef.h"
45 #include "OSGConfig.h"
52 #include "OSGdctptypes.h"
57 class OSG_DRAWABLE_DLLMAPPING DirectedEdge
60 bool direction
; // true if directed
61 int from
; // starting node
62 int to
; // ending node
66 typedef std::vector
<DirectedEdge
<T1
> > edgevector
;
69 direction(true), from(0), to(0), valid(false), edgeinfo() {}
74 class OSG_DRAWABLE_DLLMAPPING DirectedNode
77 DCTPivector edges
; // vector (pointers) of edges going to/from this node
80 typedef std::vector
<DirectedNode
<T0
> > nodevector
;
82 DirectedNode(void) : edges(), nodeinfo() {}
85 template <class T0
, class T1
>
86 class OSG_DRAWABLE_DLLMAPPING DirectedGraph
92 DirectedGraph(const DirectedGraph
&d
) :
100 int AddNode(T0
&n
); // add a new node
101 int AddEdge(T1
&t
, int from
, int to
, bool direction
); // add a new (possibly directed) edge
102 int DeleteEdge(int edgeidx
); // delete edge specified by the index
103 DCTPivector
& getEdges(int n
); // get all edges (indexes) from a node
104 DirectedNode
<T0
>& getNode(int nodeindex
, int &error
); // get one node
105 DirectedEdge
<T1
>& getEdge(int edgeindex
, int &error
); // get one edge
106 bool getEdgeDirection(int edgeindex
, int &error
); // get one edge's direction
107 int setEdgeDirection(int edgeindex
, int to
); // set the direction of an edge
108 int changeEdgeDirection(int edgeindex
); // change (invert) the direction of an edge
109 int FindNode(T0
&nodeinfo
);
110 int FindEdge(int from
, int to
);
112 bool isInvalid(void);
117 typename DirectedNode
<T0
>::nodevector nodes
;
118 typename DirectedEdge
<T1
>::edgevector edges
;
124 #include "OSGDirectedGraph.inl"
126 #endif // DirectedGraph.h