next up previous contents
Next: Integrating the Header Files Up: Algorithms Previous: Building Graphs

VertexMethods

Each Vertex object contains an MSet of Edge pointers representing its incident edges. Note that the storage medium is a multiset rather than a set because, in a multigraph, an Edge might be incident to the same Vertex twice. Vertex objects are never constructed explicitly by the programmer. See the Graph methods for adding vertices.

2. Operations






  ~Vertex ()



Clears the edge set before deleting the current Vertex object.









void addEdge (Edge* passed_edge)



Add passed_edge, which has already been constructed, to the edge set. NOTE: THIS METHOD SHOULD BE PRIVATE, BUT IT CANNOT BE RIGHT NOW SINCE THE FILE FORMAT PARSER CALLS IT (THE REASON FOR THE EXISTENCE OF THIS METHOD IS TO MANIPULATE SUBGRAPHS, WHICH MAY BE STORED. THE SUBGRAPH PROCESSING IN THE GRAPH CLASSES CAN BE ACCOMPLISHED BY MAKING THEM FRIENDS, BUT THE PARSER IS NOT A CLASS). PROGRAMMERS SHOULD NEVER CALL THIS. IT WILL BE MADE PRIVATE EVENTUALLY.









void removeEdge (Edge* passed_edge)



Remove passed_edge from the edge set. NOTE: THE COMMENT ABOVE APPLIES TO THIS METHOD ALSO.









char* name () const



Retrieve and return the name attribute of the vertex.









DataType type () const



Return VERTEX. (see general.h)









MSet<Edge*> incidentEdges () const



Return the edge set. Note that this is an O(1) operation due to the reference counting of the Collection hierarchy (Returning a constant reference to the MSet is another alternative, but g++ 2.6.3 does not protect the set in that case; it only generates a warning).









Set<Vertex*> neighbors ()



If the graph is undirected, return all of the vertices which share an edge with this Vertex object (not including itself), otherwise return outNeighbors(). O(ds), where d is the maximum degree of a vertex in G, and s is the maximum cardinality of an edge.









Set<Vertex*> inNeighbors ()



For each incident edge, if the edge is directed, find all vertices which occur before the current vertex in the sequence. If the edge is undirected, return all verticies in the edge other than the current vertex. O(ds), where d and s are defined as above.









Set<Vertex*> outNeighbors ()



For each incident edge, if the edge is directed, find all vertices which occur after the current vertex in the sequence. If the edge is undirected, return all verticies in the edge other than the current vertex. O(ds), where d and s are defined as above.









Vertex* randomNeighbor ()



Randomly select and return a neighbor (an out-neighbor if the graph is directed. O(1)









Bool operator==(const Vertex&) const  
Bool operator<=(const Vertex&) const  
Bool operator< (const Vertex&) const  
Bool operator>=(const Vertex&) const  
Bool operator> (const Vertex&) const  
Bool operator!=(const Vertex&) const  



Compare the current vertex with another based on lexicographic ordering of vertex names.









void saveToFile (ofstream& fout, int indent)



This method outputs the infomation associated with the current vertex, including its attributes. It is not generally called by the programmer; MHyperGraph::saveToFile() calls it while writing out a graph.









friend ostream& operator<<  (ostream& stream, const Vertex& v)



Output the name of the vertex to a stream.









 
next up previous contents
Next: Integrating the Header Files Up: Algorithms Previous: Building Graphs
RHS Linux User
1/26/1998