Search code examples
c#graphquickgraph

Create very large edge and vertex graphs in C#


I am attempting to map out social networks

For example, i have person A and he has 5 followers, these followers and the person would be represented by a vertex, and then have an edge connecting them. And most likely, at least half of them are following each other, creating a big sort of "web".

I tried doing this in QuickGraph, however i ran into a few issues:

  1. The graph ends up looking like more like a flow chart then a web, example from earlier in QuickGraph:

enter image description here

  1. When i test with real data, the graph just becomes a huge, laggy, spaghetti mess of ink

What would be the best way to create this sort of graph?

For reference i am looking to make a graph that looks like this:

enter image description here


Solution

  • So the data structure you are working with is a Directed Graph - that is, the edges of your node have a direction, from follower to followed.

    It looks like you are using dot to render your graph, which is a great way to lay things out if your data has some kind of start and end - if there is an overall sense of earlier to later, sources to sinks, simpler to more complex.

    You don't really have that, and your example picture is more typical of an undirected graph. The same people that do dot also do neato, which gives you diagrams much closer to your desired picture.

    I don't know QuickGraph's API at all, but I'd look to either;

    • change the graph data structure you're creating -- try switching to something like UndirectedGraph and see if that ends up switching the render
    • see if there are options in your render method to render an undirected graph rather than a directed graph.