Question: You need to complete the implementation of insert _ edge, insert _ edge _ undirected, insert _ vertex, erase _ edge, erase _ vertex functions.
You need to complete the implementation of insertedge, insertedgeundirected, insertvertex, eraseedge, erasevertex functions.
#ifndef GRAPHH
#define GRAPHH
#include
#include
#include
#include
#include
#include
#include
Uncomment if using unorderedset to store edges with boost hash function
#include
A generic adjacencylist graph where each vertex stores a VertexProperty and
each edge stores an EdgeProperty.
template
class graph
The vertex and edge classes are forwarddeclared to allow their use in the
public section below. Their definitions follow in the private section
afterward.
class vertex;
class edge;
struct vertexhash;
struct edgehash;
struct vertexeq;
struct edgeeq;
struct edgecomp;
public:
Required public types
Unique vertex identifier
typedef sizet vertexdescriptor;
Unique edge identifier represents pair of vertex descriptors
typedef std::pair edgedescriptor;
@brief A container for the vertices. It should contain "vertex or
sharedptr
typedef std::unorderedset MyVertexContainer;
@brief A container for the edges. It should contain "edge or
sharedptr
typedef std::unorderedset MyEdgeContainer;
typedef std::set MyEdgeContainer;
@brief A container for the adjacency lists. It should contain
"edge or sharedptr
typedef std::unorderedset MyAdjEdgeContainer;
typedef std::set MyAdjEdgeContainer;
Vertex iterators
typedef typename MyVertexContainer::iterator vertexiterator;
typedef typename MyVertexContainer::constiterator constvertexiterator;
Edge iterators
typedef typename MyEdgeContainer::iterator edgeiterator;
typedef typename MyEdgeContainer::constiterator constedgeiterator;
Adjacency list iterators
typedef typename MyAdjEdgeContainer::iterator adjedgeiterator;
typedef typename MyAdjEdgeContainer::constiterator constadjedgeiterator;
Required graph operations
@brief Constructordestructor
graph : mmaxvd
~graph
clear;
graphconst graph& delete; Copy is disabled.
graph& operatorconst graph& delete; Copy is disabled.
@brief vertex iterator operations
vertexiterator verticesbeginreturn mvertices.begin;
constvertexiterator verticescbegin const return mvertices.cbegin;
vertexiterator verticesendreturn mvertices.end;
constvertexiterator verticescend const return mvertices.cend;
@brief edge iterator operations
edgeiterator edgesbeginreturn medges.begin;
constedgeiterator edgescbegin const return medges.cbegin;
edgeiterator edgesendreturn medges.end;
constedgeiterator edgescend const return medges.cend;
@brief Define accessors
sizet numvertices const return mvertices.size;
sizet numedges const return medges.size;
vertexiterator findvertexvertexdescriptor vd
vertex vvd VertexProperty;
return mvertices.find&v;
constvertexiterator findvertexvertexdescriptor vd const
vertex vvd VertexProperty;
return mvertices.find&v;
edgeiterator findedgeedgedescriptor ed
edge eedfirst, edsecond, EdgeProperty;
return medges.find&e;
constedgeiterator findedgeedgedescriptor ed const
edge eedfirst, edsecond, EdgeProperty;
return medges.find&e;
@todo Define modifiers
vertexdescriptor insertvertexconst VertexProperty& vp
return mmaxvd;
edgedescriptor insertedgevertexdescriptor sd vertexdescriptor td
const EdgeProperty& ep
return std::makepairsd td;
void insertedgeundirectedvertexdescriptor sd vertexdescriptor td
const EdgeProperty& ep
void erasevertexvertexdescriptor vd
void eraseedgeedgedescriptor ed
end of @todo
void clear
mmaxvd ;
forauto v : mvertices
delete v;
mvertices.clear;
forauto e : medges
delete e;
medges.clear;
Friend declarations for inputoutput
template
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
