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?
Asked
Active
Viewed 2,785 times
0
-
You want to "parse C++ to XML"? And why don´t you write some own data classes for your use case? Not everything is the standard lib... – deviantfan Jan 23 '15 at 14:28
-
In C++ it doesn't matter, the only difference between a `class` and a `struct` is the default member visibility (`private` versus `public`). And in C it's a moot point since C doesn't have classes. And would say that *any* topology is a graph. – Some programmer dude Jan 23 '15 at 14:30
-
1@JoachimPileborg not in math ;) – vsoftco Jan 23 '15 at 14:34
2 Answers
3
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
1
There are plenty of good C++ XML parser API's out there, see: What XML parser should I use in C++?
There are also plenty of good networking libraries out there, see: Best C/C++ Network Library