Directed Graph

build, modify, and query graph of nodes

1.0 Concept

Fig 1. Graph Structure
Graphs are very useful for capturing relationships, e.g., dependencies between packages. This repository contains a Graph<V, E,>, where V is a Vertex class and E is an Edge class. The intent of this design is to support Vertices and Edges that may contain information as data members. For example, if we need to capture relationships between a set of classes, each vertex contains a class name and each edge contains a relationship type, e.g., inheritence, composition, aggregation, or using.

2.0 Design

Each vertex contains a std::vector<Edge> and each graph contains a std::vector<Vertex>. Each edge has an associated int that is an index into graph's vertex collection to refer to a specific child node. It is much easier to ensure memory safety using indexes into the adjacency list as compared to referencing with pointers. By safety we mean always pointing to owned memory and reclaiming memory when no longer used.

3.0 Status

I'm considering changing the class definitions and their data structures, in order to simplify the design. Note that the current implementation is fully functional, so this redesign probably won't happen for awhile.