Difference between revisions of "SimpleGraph"

From BITPlan Wiki
Jump to navigation Jump to search
Line 22: Line 22:
 
   digraph FileSystemGraph {
 
   digraph FileSystemGraph {
 
     rankdir="RL";
 
     rankdir="RL";
        "header.txt" -> "etc" [ label="parent"]
+
"src" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src"
        "SimpleGraphImpl.java" -> "impl" [ label="parent"]
+
"java" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/java"
        "test" -> "src" [ label="parent"]
+
"test" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/test"
        "java" -> "main" [ label="parent"]
+
"simplegraph" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/test/java/com/bitplan/simplegraph"
        "RythmContext.java" -> "rythm" [ label="parent"]
+
"FileNode.java" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/java/com/bitplan/filesystem/FileNode.java"
        "etc" -> "src" [ label="parent"]
+
"RythmContext.java" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/java/com/bitplan/rythm/RythmContext.java"
        "rythm" -> "main" [ label="parent"]
+
"rythm" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/rythm"
        "test.rythm" -> "rythm" [ label="parent"]
+
"BaseTest.java" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/test/java/com/bitplan/simplegraph/BaseTest.java"
        "main" -> "src" [ label="parent"]
+
"etc" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/etc"
        "com" -> "java" [ label="parent"]  
+
"impl" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/java/com/bitplan/simplegraph/impl"
        "graphvizTree.rythm" [  URL="[https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/rythm/graphvizTree.rythm]"]
+
"test.rythm" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/rythm/test.rythm"
        "graphvizTree.rythm"-> "rythm" [ label="parent"]
+
"com" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/java/com"
        "air-routes-small.graphml" -> "test" [ label="parent"]
+
"TestRythm.java" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/test/java/com/bitplan/simplegraph/TestRythm.java"
        "bitplan" -> "com" [ label="parent"]
+
"main" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main"
        "java" -> "test" [ label="parent"]
+
"SimpleGraph.java" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/java/com/bitplan/simplegraph/SimpleGraph.java"
        "filesystem" -> "bitplan" [ label="parent"]
+
"graphvizTree.rythm" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/rythm/graphvizTree.rythm"
        "air-routes.graphml" -> "test" [ label="parent"]
+
"TestTinkerPop3.java" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/test/java/com/bitplan/simplegraph/TestTinkerPop3.java"
        "simplegraph" -> "bitplan" [ label="parent"]
+
"air-routes-small.graphml" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/test/air-routes-small.graphml"
        "com" -> "java" [ label="parent"]
+
"bitplan" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/java/com/bitplan"
        "rythm" -> "bitplan" [ label="parent"]
+
"SimpleNode.java" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/java/com/bitplan/simplegraph/SimpleNode.java"
        "bitplan" -> "com" [ label="parent"]
+
"TestFileSystem.java" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/test/java/com/bitplan/simplegraph/TestFileSystem.java"
        "FileSystem.java" -> "filesystem" [ label="parent"]
+
"java" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/test/java"
        "simplegraph" -> "bitplan" [ label="parent"]
+
"filesystem" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/java/com/bitplan/filesystem"
        "FileNode.java" -> "filesystem" [ label="parent"]
+
"SimpleSystem.java" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/java/com/bitplan/simplegraph/SimpleSystem.java"
        "BaseTest.java" -> "simplegraph" [ label="parent"]
+
"TestDebug.java" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/test/java/com/bitplan/simplegraph/TestDebug.java"
        "impl" -> "simplegraph" [ label="parent"]
+
"air-routes.graphml" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/test/air-routes.graphml"
        "TestRythm.java" -> "simplegraph" [ label="parent"]
+
"simplegraph" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/java/com/bitplan/simplegraph"
        "SimpleGraph.java" -> "simplegraph" [ label="parent"]
+
"SimpleSystemImpl.java" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/java/com/bitplan/simplegraph/impl/SimpleSystemImpl.java"
        "TestTinkerPop3.java" -> "simplegraph" [ label="parent"]
+
"TestSuite.java" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/test/java/com/bitplan/simplegraph/TestSuite.java"
        "SimpleNode.java" -> "simplegraph" [ label="parent"]
+
"com" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/test/java/com"
        "TestFileSystem.java" -> "simplegraph" [ label="parent"]
+
"rythm" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/java/com/bitplan/rythm"
        "SimpleSystem.java" -> "simplegraph" [ label="parent"]
+
"SimpleNodeImpl.java" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/java/com/bitplan/simplegraph/impl/SimpleNodeImpl.java"
        "TestDebug.java" -> "simplegraph" [ label="parent"]
+
"header.txt" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/etc/header.txt"
        "SimpleSystemImpl.java" -> "impl" [ label="parent"]
+
"bitplan" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/test/java/com/bitplan"
        "TestSuite.java" -> "simplegraph" [ label="parent"]
+
"FileSystem.java" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/java/com/bitplan/filesystem/FileSystem.java"
        "SimpleNodeImpl.java" -> "impl" [ label="parent"]
+
"SimpleGraphImpl.java" [ URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master//Users/wf/Documents/workspace/com.bitplan.simplegraph/src/main/java/com/bitplan/simplegraph/impl/SimpleGraphImpl.java"
 +
"header.txt"->"etc" [label="parent"]
 +
"SimpleGraphImpl.java"->"impl" [label="parent"]
 +
"test"->"src" [label="parent"]
 +
"java"->"main" [label="parent"]
 +
"RythmContext.java"->"rythm" [label="parent"]
 +
"etc"->"src" [label="parent"]
 +
"rythm"->"main" [label="parent"]
 +
"test.rythm"->"rythm" [label="parent"]
 +
"main"->"src" [label="parent"]
 +
"com"->"java" [label="parent"]
 +
"graphvizTree.rythm"->"rythm" [label="parent"]
 +
"air-routes-small.graphml"->"test" [label="parent"]
 +
"bitplan"->"com" [label="parent"]
 +
"java"->"test" [label="parent"]
 +
"filesystem"->"bitplan" [label="parent"]
 +
"air-routes.graphml"->"test" [label="parent"]
 +
"simplegraph"->"bitplan" [label="parent"]
 +
"com"->"java" [label="parent"]
 +
"rythm"->"bitplan" [label="parent"]
 +
"bitplan"->"com" [label="parent"]
 +
"FileSystem.java"->"filesystem" [label="parent"]
 +
"simplegraph"->"bitplan" [label="parent"]
 +
"FileNode.java"->"filesystem" [label="parent"]
 +
"BaseTest.java"->"simplegraph" [label="parent"]
 +
"impl"->"simplegraph" [label="parent"]
 +
"TestRythm.java"->"simplegraph" [label="parent"]
 +
"SimpleGraph.java"->"simplegraph" [label="parent"]
 +
"TestTinkerPop3.java"->"simplegraph" [label="parent"]
 +
"SimpleNode.java"->"simplegraph" [label="parent"]
 +
"TestFileSystem.java"->"simplegraph" [label="parent"]
 +
"SimpleSystem.java"->"simplegraph" [label="parent"]
 +
"TestDebug.java"->"simplegraph" [label="parent"]
 +
"SimpleSystemImpl.java"->"impl" [label="parent"]
 +
"TestSuite.java"->"simplegraph" [label="parent"]
 +
"SimpleNodeImpl.java"->"impl" [label="parent"]
 
   }
 
   }
 
</graphviz>
 
</graphviz>

Revision as of 16:38, 13 January 2018

SimpleGraph

SimpleGraph is an open source project that allows to wrap Systems APIs in a way that graph algorithms and storage can be applied. As an implementation Apache Gremlin/Tinkerpop is used.

FileSystem example

Basics

A Filesystem is a graph. It consists of File and Directory nodes

There is parent-child relation between Directories and their subfiles. A Directory may contain files and directories. A file is always leaf of the the tree. A directory may be a leaf if it's empty. In our example we'll go from directories to the containing elements via the "files" edge/relation and from the files/directories to their parents via the "parent" edge.

Example goal

We'd like to analyze some part of a filesystem and we'll use the "src" directory of the SimpleGraph project's source code as a starting point.

The graph below shows the source code structure for the SimpleGraph project with the root of the tree being the "src" directory. The nodes are clickable and will lead you to the corresponding file representation on github.

explanation

creating the graph

This graph visualization has been produced with the following Java lines which make sure that the "src" Directory can be handled as a gremlin graph:

 // create a new FileSystem acces supplying the result as a SimpleSystem API
 SimpleSystem fs=new FileSystem();  
 // connect to this system with no extra information (e.g. no credentials) and move to the "src" node 
 SimpleNode start = fs.connect("").moveTo("src");
 // do gremlin style out traversals recusively to any depth 
 start.recursiveOut("files",Integer.MAX_VALUE);

converting the graph to graphviz

The graph is now available and can be traversed to create a graphviz version of it. We use the Template:Rythm template engine to do so. Within Rythm you can use Java code.


In Internet Explorer versions up to 8, things inside the canvas are inaccessible!