Core Mesh Data Structures in C++


Graph

The Graph class is a subclass of the abstract class Edges. The methods getNumberOfVertices(), getNumberOfEdges(), getEdge(iV0,iV1), getVertex0(iE), and getVertex1(iE) are inherited from the Edges class.

 class Graph : public Edges {
   public:
             Graph(const int V);
     void    reset();
     int     insertEdge(const int iV0, const int iV1);
     // int  getNumberOfVertices()                     const;
     // int  getNumberOfEdges()                        const;
     // int  getEdge(const int iV0, const int iV1)     const;
     // int  getVertex0(const int iE)                  const;
     // int  getVertex1(const int iE)                  const;
 }

The constructor Graph(V) creates a graph with vertices 0,...,V-1 and no edges. The method resate() deletes all the edges but keeps the vertices.

If the edge (iV0,iV1) does not belong to the graph edges, then the method insertEdge(iV0,iV1) adds the edge to the set of edges of the graph, assigns the edge a unique edge index, and returns the edge index value. On the other hand, if the edge (iV0,iV1) already belongs to the graph edges, then the method insertEdge(iV0,iV1) returns the value -1.

Note that this data structure does not allow individual edges to be deleted. As a result, the method insertEdge(iV0,iV1) is implemented so that it returns consecutive edge indices starting with 0 as it creates new edges.

Next : HalfEdges


Core Mesh | Faces | Edges | Graph | HalfEdges | Partition | PolygonMesh | Queue