DGraph - YosefTwito/PackIt GitHub Wiki

  • This interface represents a directional weighted graph.
  • The interface has a road-system or communication network in mind - and should support a large number of nodes (over 100,000).
  • The implementation is based on an efficient compact representation (fast run-time).
  • @authors YosefTwito and EldarTakach

The DGraph:

DGraph's parameters:

  1. HashMap<Integer, node_data> nodesMap - contain all the nodes in the graph.
  2. HashMap<Integer, HashMap<Integer,edge_data>> edgesMap - contain all the edges in the graph.
  3. int edgesCounter.
  4. int MC (mode counter).

The functions of the DGraph are:

Constructor:

  • DGraph().
  • DGraph(DGraph G)

Methods:

  1. getNode(int key) - get a key and return the node with the given key.
  2. getEdge(int src, int dest) - get src and dst, return the edge from src-node to dest-node.
  3. addNode(node_data n) - add the given node to my nodeMap.
  4. connect(int src, int dest, double w) - create new edge from the given src-node to the given dest-node with weight=w.
  5. getV() - return a pointer (shallow copy) for the collection representing all the nodes in the graph.
  6. getE(int node_id) - return a pointer (shallow copy) for the collection representing all the edges getting out of the given node.
  7. removeNode(int key) - remove the node with the given id and all the edges related to it from the graph.
  8. removeEdge(int src, int dest) - remove the edge with the given parameters from the graph.
  9. nodeSize() - return the amount of nodes in the graph.
  10. edgeSize() - return the amount of edges in the graph.
  11. getMC() - return the MC(mode counter).