Search code examples
c++cnetwork-programminggraphtopology

Network topology in c/c++


I'm trying to define a network topology in C/C++ language. The goal is to parse it from C/C++ to XML and viceversa. In this topology (as you see in the picture) routers are connected with interfaces; each of them have an ip address and a link capacity. Are there classes (like graphs) or structs to implement easier a network topology?

topology


Solution

  • Network topology is simply a graph.

    The most popular representations of the graph are adjacency list/matrix. Adjacency list node has the following structure (for ex.):

    template <class T>
    struct Node {
        T data;
        std::vector<Node*> childs;
    };
    

    If you later want to use graph algorithms, better use adjacency matrix Adjacent matrix