Skip to content

Graph development #7

Description

@GoogleCodeExporter
Hi, Alexandra!

Your first task is Graph development.

The Graph class represents graph as a whole. Graph should be directed, and 
should allow to add edges that has same predecessor node and same successor 
node (this graph is called as multigraph). Internally, graph should be 
represented as incidence list. 
So, you need to create special classes of vertex objects (Node) and edge 
objects (Edge). Each node should have list of incoming edges and list of 
outcoming edge. In turn, each edge object has two vertex objects at its 
endpoints (predecessor and successor). 

Expected list of features:
1) Traversing nodes and edges. For traversing possibility, nodes and edges must 
be linked in two lists. Need to implement Graph::firstNode() and 
Graph::firstEdge() routines with calling Node::nextNode(), Edge::nextEdge()
 //Traversing nodes, type of g is Graph*
 for ( Node *n = g->firstNode(); n != null; n = n->nextNode())
 {
     ...
 }
 //Traversing edges
 for ( Edge *e = g->firstEdge(); e != null; e = e->nextEdge())
 {
     ...
 }

Above code is possible example of traversing. You can design it in another way, 
you should only provide possibility for traversing.

2) Traversing Node's predecessors and successors. Implement functions: 
Node::firstPred(), Node::firstSucc(), Edge::nextPred(), Edge::nextSucc()
  // Traversing edges simple, type of n is Node*
  for ( Edge* e = n->firstPred(); e != null; e = e->nextPred())
  {
     ...
  }

Graph must be implemented in sources/graph directory. Classes Graph, Node, Edge 
should be implemented seperately (e.g. sources/graph/graph.hpp, 
sources/graph/node.hpp, sources/graph/edge.hpp)

Also you need to add unit tests of graph. 
Skeleton will be provided soon.

Don't hesitate to ask me for clarifying this task.

Original issue reported on code.google.com by rob.khas...@gmail.com on 23 Nov 2013 at 10:42

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions