Search code examples
anylogicgephi

Use Gephi to display graphs in AnyLogic


I've created an agent based model in AnyLogic and would like to visualize the graph. Ideally I'd like to use something like Gephi.

I've used the general visualization tools that come with AnyLogic to create a circle layout, but I'd much rather have something that is more useful, such as the Force Atlas 2.

Ideally, I'd like to have the graph visualized directly in one of the view areas. Any ideas? It seems that AnyLogic is awfully limiting in what you can do visually outside of its pre-packaged components (as vast as they are in their own right).


Solution

  • I agree that Gephi is a powerful tool for working with graphs, but I haven`t directly used it in AnyLogic so far. Here is how I would try do it:

    1. Download the Gephi Toolkit as a Java jar
    2. Integrate it in your AnyLogic project: In the Project tab in your model's properties under Dependencies / Jar files and class folders add the downloaded jar file
    3. Add the namespaces to your project by adding in your Main under Advanced Java / Imports Section (Here the example for the needed namespaces to generate graphs):
    import org.openide.util.Lookup;
    import org.gephi.project.api.Workspace;
    import org.gephi.io.importer.api.Container;
    import org.gephi.io.generator.plugin.RandomGraph;
    import org.gephi.io.importer.api.ImportController;
    import org.gephi.io.processor.plugin.DefaultProcessor;
    import org.gephi.io.processor.plugin.AppendProcessor;
    import org.gephi.io.generator.plugin.DynamicGraph;
    
    1. Generate a graph, described in this example.

    The only difficult or impossible thing might be integrating visualisation into the AnyLogic canvas. However you can always have a "popup" window as a JFrame as in this example.