Does anyone have a simple example of using GraphViz to read DOT files and traverse its graph? The site's documentation doesn't seem to have any.
I should note that I cannot use Boost. I need to use cgraph.
I have many such answers on site:
Using Boost Graph Library
boost::read_graphviz - how to read out properties?
read_graphviz() in Boost::Graph, pass to constructor
Odd Error Importing DOT files
Get a copy of a boost graph that is reversed
Using two objects as hash key for an unordered_map or alternatives
How does the attractive force of Fruchterman Reingold work with Boost Graph Library
Using libcgraph
Sadly I cannot find that answer ... o.O
I'm absolutely convinced I wrote an answer using that here before, because I spent considerable amount of time on it. Perhaps you have better luck finding it.
Related
I would like to convert a struct from c source code (same file) (which can include more structs of structs) and I would like to walk that "structure". Is there an optimal way to do this? Some sort of Tree class that I could convert to a graphical tree would be nice. At the farthest "leaf" struct, I'll want to be able to access the struct members also, not just the tree structure of the structs. I'm open to any algorithms. This strikes me as a recursive type algorithm. I just don't want to waste time reinventing the wheel. No it's not homework, but it is work related :) . If any knows of preexisting tools that already do this. I can provide more details below if anyone needs them.
If you are just documenting your code, I recommend using doxygen software.
If you are to parse your code file, take a look at boost libraries:
This example might give you some motivation.
For graphic displaying I can't recommend anything c++ but maybe NodeBox which is based on boost.
Nevertheless, C++ is probably not the right tool of choice for tasks like this. Try rather (say) python.
As a last option, you can also go and do your own recursive traverser and output your data into an / that can be read by some graph displaying program.
How fast is Graphiz? I want to implement a profiler which keeps track of threads state. I want to build and visualize waits-for graphs in real time (!).
Is this even possible? Would Graphviz be the appropriate match?
Otherwise, are there alternative for C++?
I would not use Graphviz because it is designed for creating graphical visualization of graph structures. Instead, might I suggest using the Boost Graph Library? While I have not used it personally, the Boost libraries are well respected, and it seems to be everywhere when I try to look for graphs in c++. I think that you will find the boost implementation will meet your needs.
I'm rusty on C++ templates and I'm using the boost graph library (a fatal combination). I've searched the web and can't find any direct instructions on how to take a custom graph structure and fit enough of it to BGL (boost graph library) that I can use boosts graph traversing algorithms. Anyone familiar enough with the library to help me out?
EDIT: So, the main problem I've been having is where to find a source where the total requirements to map an arbitrary graph to a BGL graph. I'm really new to templates so it's hard for me to read BGL's specification/examples. Maybe I should look for a general source on templates?
My suggestion would be to abandon use of BGL entirely unless you already have a significant amount of code written on top of it. I was testing it out recently for future use on a large graph analysis project, and I found it to be almost unusable due to an overly complex and poorly designed API.
There are no simple tasks in BGL, only complex ones, and I was constantly fighting the compiler due to the excessively complicated template hierarchy that BGL has. Little to no useful documentation (at least not where it's really needed) and not enough examples only aggravate matters. That's no way to write code.
I'd recommend switching to LEMON. It's stable, written in C++, easy-to-understand and code in, offers several specialized forms of graphs to support different usage needs, and it supports both BFS and DFS search/visitor functions. It also has its own equivalent of property maps for nodes/edges, so you should be able to fit your own graph structure and other data onto it.
Try LEMON; it tastes a lot better and will cause fewer ulcers. ;-)
The approach, as I understand it, is to specialize the boost::graph_traits structure for your graph type. This configures BGL with various important properties it needs to know about your graph. You then specialize global template functions for your graph's specialized type of graph_traits to implement whatever boost graph interfaces might apply to your specific kind of graph.
An example is right there in the BGL documentation:
http://www.boost.org/doc/libs/1_43_0/libs/graph/doc/leda_conversion.html
There are links for several of the different interfaces there, which indicate which global template functions you'll need to specialize for your graph if you want to support that interface. The full list of interfaces is here:
http://www.boost.org/doc/libs/1_43_0/libs/graph/doc/graph_concepts.html
I am working on a research project that deals with social networks. I have done most of the backbone of the program in C++ and am now wanting to implement a way to create the graph of nodes and the connections as well as a way to visualize the connections between people. I have looked a little into Lemon and the Boost graph library, but was wondering which one would be easier to learn and implement or if I should just code my own.
If you use the BGL then you should also be able to make use of the Graph Toolkit for Algorithms and Drawings (GTAD). The GTAD is meant to be compatible with BGL and adds a number of graph algorithms not in BGL as well as algorithms for layouts.
For visualization the BGL allows you to read and write some common graph file types such as GraphML and Dot for use with GraphViz.
Lemon looks to be a well featured library with a good array of algorithms. You can also use gLemon to view Lemon graphs. This visualizer looks quite basic though and was last updated in 2008, unlike Lemon which is still under development.
I would suggest you first work out what you want to do with any graphs you create, ie what algorithms you require (shortest-path etc) and compare the two libraries from that respect.
Also take a look at the tutorials for both. They have very good documentation and should help you decide which you'll find easier to implement.
Unless you really want to get into the details of how certain graph structures and algorithms are implemented I would use a library.
Could anyone point me to an example implementation of a HOT Queue or give some pointers on how to approach implementing one?
Here is a page I found that provides at least a clue toward what data structures you might use to implement this. Scroll down to the section called "Making A* Scalable." It's unfortunate that the academic papers on the subject mention having written C++ code but don't provide any.
Here is the link to the paper describing HOT queues. It's very abstract, that's why i wanted
to see a coded example (I'm still trying to fin my way around it).
http://www.star-lab.com/goldberg/pub/neci-tr-97-104.ps
The "cheapest", sort to speak variant of this is a two-level heap queue (maybe this sounds more familiar). What i wanted to do is to improve the running time of the Dijkstra's shortest path algorithm.
What i wanted to do is to improve the
running time of the Dijkstra's
shortest path algorithm.
Have you considered using the Boost Graph Library?
If you are using your own implementation of the algorithm you might already get better results using the one the BGL provides.
However It might be nontrivial to modify your code so it works with the BGL.
Of course speed-up could also be gained by not using Dijkstra at all but another algorithm.