Dgraph - NoaAizer/Graphs GitHub Wiki
We implemented the graph interface in Dgraph:
The graph is a collection of nodes and edges.
We implemented the nodes and edges by the data structure – HashMap.
nodes - key as Integer value represents the key of a vertex and value is the pointer to the actual vertex.
edges - node_data as key and value is a HashMap of edges with destination as key and edge_data representing the edge as value.
edgesCounter - counts the amount of edges.
mc - counts the number of actions taken on the graph.
DGraph function:
- Constructors- creates an empty graph (default constructor) and builds a new graph from a given graph.
- getNode- return the node_data by the node_id (key - the node_id), null if none.
- getEdge - return the data of the edge (src,dest), null if none
- addNode - add a new node to the graph with the given node_data (n represents the given node).
- connect - Connect an edge with weight w between node src to node dest, (src - the source of the edge, dest - the destination of the edge, w - positive weight representing the cost between src-->dest).
- Collection<node_data> getV() - his method return a pointer (shallow copy) for the collection representing all the nodes in the graph, Collection<node_data> represents a list of the nodes in the graph.
- Collection<edge_data> getE - This method return a pointer (shallow copy) for the collection representing all the edges getting out of the given node (all the edges starting (source) at the given node), Collection<edge_data> represents a list of the edges in the graph.
- node_data removeNode - Delete the node (with the given ID) from the graph - and removes all edges which starts or ends at this node, (key represents the ID of the requested node). return the data of the removed node (null if none).
- removeEdge - Delete the edge from the graph, (src represents the source node, dest represents the destination node). return the data of the removed edge (null if none).
- nodeSize() - return the number of vertices (nodes) in the graph.
- edgeSize() - return the number of edges (assume directional graph).
- getMC() - return the Mode Count - for testing changes in the graph.
- getNodes() - Nodes getter, return the hashmap that contains all the nodes.
- getEdges() - Edges getter, return the hashmap that contains all the edges.