Difference between revisions of "SimpleGraph"

From BITPlan Wiki
Jump to navigation Jump to search
Line 1: Line 1:
 
{{Article|title=SimpleGraph|text=[https://github.com/BITPlan/com.bitplan.simplegraph SimpleGraph]
 
{{Article|title=SimpleGraph|text=[https://github.com/BITPlan/com.bitplan.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.
 
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 ==
+
= Modules =
A Filesystem is a graph. It consists of File and Directory nodes
+
# {{Link|target=SimpleGraph-FileSystem}}
<graphviz>
+
 
  digraph FileSystem {
 
    Directory -> File [ label="files" ]
 
    Directory -> Directory [ label="files" ]
 
    File -> Directory [ label="parent" ]
 
    Directory -> Directory [ label="parent" ]
 
  }
 
</graphviz>
 
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.
 
=== Example FileSystem Graph of "src" directory ===
 
The nodes of this graph are clickable and will lead you to the source pages in the github repository of this project.
 
<!--
 
  this graph was generated 2018-01-26 16:48:51
 
  by the graphvizTree.rythm template
 
  see http://wiki.bitplan.com/index.php/SimpleGraph
 
-->
 
<graphviz>
 
  digraph FileSystemGraphForSrcDirectoryOfSimpleGraphGitHubOpenSourceProject {
 
    rankdir="RL";
 
    "src/test/java/com" [ label="com" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/java/com"]
 
    "src" [ label="src" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src"]
 
    "src/main/java/com/bitplan/mediawiki/MediaWikiSystem.java" [ label="MediaWikiSystem.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/mediawiki/MediaWikiSystem.java"]
 
    "src/test/java/com/bitplan/simplegraph/TestJson.java" [ label="TestJson.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/java/com/bitplan/simplegraph/TestJson.java"]
 
    "src/main/java/com/bitplan/powerpoint" [ label="powerpoint" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/powerpoint"]
 
    "src/main/java/com/bitplan/json/JsonNode.java" [ label="JsonNode.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/json/JsonNode.java"]
 
    "src/test" [ label="test" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test"]
 
    "src/main/java/com/bitplan/simplegraph/SimpleSystem.java" [ label="SimpleSystem.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/simplegraph/SimpleSystem.java"]
 
    "src/test/java/com/bitplan" [ label="bitplan" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/java/com/bitplan"]
 
    "src/main/rythm/test.rythm" [ label="test.rythm" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/rythm/test.rythm"]
 
    "src/test/java/com/bitplan/simplegraph/TestDebug.java" [ label="TestDebug.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/java/com/bitplan/simplegraph/TestDebug.java"]
 
    "src/main/java/com/bitplan/simplegraph" [ label="simplegraph" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/simplegraph"]
 
    "src/main/java/com/bitplan/json/JsonPrettyPrinter.java" [ label="JsonPrettyPrinter.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/json/JsonPrettyPrinter.java"]
 
    "src/etc" [ label="etc" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/etc"]
 
    "src/main/java/com/bitplan/simplegraph/impl/Holder.java" [ label="Holder.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/simplegraph/impl/Holder.java"]
 
    "src/test/java/com/bitplan/simplegraph" [ label="simplegraph" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/java/com/bitplan/simplegraph"]
 
    "src/main/rythm/graphvizTree.rythm" [ label="graphvizTree.rythm" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/rythm/graphvizTree.rythm"]
 
    "src/test/java/com/bitplan/simplegraph/TestSuite.java" [ label="TestSuite.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/java/com/bitplan/simplegraph/TestSuite.java"]
 
    "src/main/java/com/bitplan/wikidata" [ label="wikidata" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/wikidata"]
 
    "src/main/java/com/bitplan/json/JsonSystem.java" [ label="JsonSystem.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/json/JsonSystem.java"]
 
    "src/main" [ label="main" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main"]
 
    "src/main/java/com/bitplan/simplegraph/impl/SimpleSystemImpl.java" [ label="SimpleSystemImpl.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/simplegraph/impl/SimpleSystemImpl.java"]
 
    "src/test/java/com/bitplan/simplegraph/TestSMW.java" [ label="TestSMW.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/java/com/bitplan/simplegraph/TestSMW.java"]
 
    "src/etc/header.txt" [ label="header.txt" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/etc/header.txt"]
 
    "src/main/java/com/bitplan/smw" [ label="smw" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/smw"]
 
    "src/main/java/com/bitplan/powerpoint/SlideShowNode.java" [ label="SlideShowNode.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/powerpoint/SlideShowNode.java"]
 
    "src/test/employee.json" [ label="employee.json" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/employee.json"]
 
    "src/main/java/com/bitplan/simplegraph/impl/KeysImpl.java" [ label="KeysImpl.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/simplegraph/impl/KeysImpl.java"]
 
    "src/test/java/com/bitplan/simplegraph/BaseTest.java" [ label="BaseTest.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/java/com/bitplan/simplegraph/BaseTest.java"]
 
    "src/main/java" [ label="java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java"]
 
    "src/main/java/com/bitplan/rythm" [ label="rythm" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/rythm"]
 
    "src/main/java/com/bitplan/powerpoint/SlideImage.java" [ label="SlideImage.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/powerpoint/SlideImage.java"]
 
    "src/test/air-routes-small.graphml" [ label="air-routes-small.graphml" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/air-routes-small.graphml"]
 
    "src/main/java/com/bitplan/simplegraph/impl/SimpleNodeImpl.java" [ label="SimpleNodeImpl.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/simplegraph/impl/SimpleNodeImpl.java"]
 
    "src/test/java/com/bitplan/simplegraph/TestMediaWiki.java" [ label="TestMediaWiki.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/java/com/bitplan/simplegraph/TestMediaWiki.java"]
 
    "src/main/rythm" [ label="rythm" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/rythm"]
 
    "src/main/java/com/bitplan/mediawiki" [ label="mediawiki" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/mediawiki"]
 
    "src/main/java/com/bitplan/powerpoint/SlideShow.java" [ label="SlideShow.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/powerpoint/SlideShow.java"]
 
    "src/test/resources" [ label="resources" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/resources"]
 
    "src/main/java/com/bitplan/simplegraph/impl/Cache.java" [ label="Cache.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/simplegraph/impl/Cache.java"]
 
    "src/test/java/com/bitplan/simplegraph/TestRythm.java" [ label="TestRythm.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/java/com/bitplan/simplegraph/TestRythm.java"]
 
    "src/main/java/com" [ label="com" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com"]
 
    "src/main/java/com/bitplan/gremlin/RegexPredicate.java" [ label="RegexPredicate.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/gremlin/RegexPredicate.java"]
 
    "src/main/java/com/bitplan/powerpoint/SlideNode.java" [ label="SlideNode.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/powerpoint/SlideNode.java"]
 
    "src/test/java" [ label="java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/java"]
 
    "src/main/java/com/bitplan/simplegraph/impl/SimpleGraphImpl.java" [ label="SimpleGraphImpl.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/simplegraph/impl/SimpleGraphImpl.java"]
 
    "src/test/java/com/bitplan/simplegraph/TestWikiData.java" [ label="TestWikiData.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/java/com/bitplan/simplegraph/TestWikiData.java"]
 
    "src/main/java/com/bitplan" [ label="bitplan" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan"]
 
    "src/main/java/com/bitplan/triplestore/TripleStoreSystem.java" [ label="TripleStoreSystem.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/triplestore/TripleStoreSystem.java"]
 
    "src/main/java/com/bitplan/powerpoint/PowerPointSystem.java" [ label="PowerPointSystem.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/powerpoint/PowerPointSystem.java"]
 
    "src/test/air-routes.graphml" [ label="air-routes.graphml" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/air-routes.graphml"]
 
    "src/main/java/com/bitplan/wikidata/WikiDataNode.java" [ label="WikiDataNode.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/wikidata/WikiDataNode.java"]
 
    "src/test/java/com/bitplan/simplegraph/TestTinkerPop3.java" [ label="TestTinkerPop3.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/java/com/bitplan/simplegraph/TestTinkerPop3.java"]
 
    "src/main/java/com/bitplan/gremlin" [ label="gremlin" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/gremlin"]
 
    "src/main/java/com/bitplan/triplestore/TripleNode.java" [ label="TripleNode.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/triplestore/TripleNode.java"]
 
    "src/main/java/com/bitplan/powerpoint/Slide.java" [ label="Slide.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/powerpoint/Slide.java"]
 
    "src/test/menu.json" [ label="menu.json" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/menu.json"]
 
    "src/main/java/com/bitplan/wikidata/WikiDataSystem.java" [ label="WikiDataSystem.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/wikidata/WikiDataSystem.java"]
 
    "src/test/java/com/bitplan/simplegraph/TestFileSystem.java" [ label="TestFileSystem.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/java/com/bitplan/simplegraph/TestFileSystem.java"]
 
    "src/main/java/com/bitplan/triplestore" [ label="triplestore" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/triplestore"]
 
    "src/main/java/com/bitplan/filesystem/FileSystem.java" [ label="FileSystem.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/filesystem/FileSystem.java"]
 
    "src/main/java/com/bitplan/simplegraph/impl" [ label="impl" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/simplegraph/impl"]
 
    "src/test/pets.json" [ label="pets.json" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/pets.json"]
 
    "src/main/java/com/bitplan/smw/SMWSystem.java" [ label="SMWSystem.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/smw/SMWSystem.java"]
 
    "src/test/java/com/bitplan/simplegraph/TestTripleStore.java" [ label="TestTripleStore.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/java/com/bitplan/simplegraph/TestTripleStore.java"]
 
    "src/main/java/com/bitplan/filesystem" [ label="filesystem" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/filesystem"]
 
    "src/main/java/com/bitplan/filesystem/FileNode.java" [ label="FileNode.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/filesystem/FileNode.java"]
 
    "src/main/java/com/bitplan/simplegraph/SimpleGraph.java" [ label="SimpleGraph.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/simplegraph/SimpleGraph.java"]
 
    "src/test/resources/sidif" [ label="sidif" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/resources/sidif"]
 
    "src/main/java/com/bitplan/rythm/RythmContext.java" [ label="RythmContext.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/rythm/RythmContext.java"]
 
    "src/test/java/com/bitplan/simplegraph/TestPowerPoint.java" [ label="TestPowerPoint.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/java/com/bitplan/simplegraph/TestPowerPoint.java"]
 
    "src/main/java/com/bitplan/map" [ label="map" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/map"]
 
    "src/main/java/com/bitplan/map/MapNode.java" [ label="MapNode.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/map/MapNode.java"]
 
    "src/main/java/com/bitplan/simplegraph/Keys.java" [ label="Keys.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/simplegraph/Keys.java"]
 
    "src/test/resources/sidif/royal92.sidif" [ label="royal92.sidif" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/resources/sidif/royal92.sidif"]
 
    "src/main/java/com/bitplan/mediawiki/MediaWikiPageNode.java" [ label="MediaWikiPageNode.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/mediawiki/MediaWikiPageNode.java"]
 
    "src/test/java/com/bitplan/simplegraph/TestMapSystem.java" [ label="TestMapSystem.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/java/com/bitplan/simplegraph/TestMapSystem.java"]
 
    "src/main/java/com/bitplan/json" [ label="json" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/json"]
 
    "src/main/java/com/bitplan/map/MapSystem.java" [ label="MapSystem.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/map/MapSystem.java"]
 
    "src/main/java/com/bitplan/simplegraph/SimpleNode.java" [ label="SimpleNode.java" URL="https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/java/com/bitplan/simplegraph/SimpleNode.java"]
 
    "src/test/java/com/bitplan/simplegraph/TestMapSystem.java" -> "src/test/java/com/bitplan/simplegraph" [ label="parent"]
 
    "src/main/java/com/bitplan/map/MapSystem.java" -> "src/main/java/com/bitplan/map" [ label="parent"]
 
    "src/main/java/com/bitplan/mediawiki/MediaWikiSystem.java" -> "src/main/java/com/bitplan/mediawiki" [ label="parent"]
 
    "src/test/java/com/bitplan/simplegraph/TestJson.java" -> "src/test/java/com/bitplan/simplegraph" [ label="parent"]
 
    "src/main/java/com/bitplan/json/JsonNode.java" -> "src/main/java/com/bitplan/json" [ label="parent"]
 
    "src/test" -> "src" [ label="parent"]
 
    "src/main/rythm/test.rythm" -> "src/main/rythm" [ label="parent"]
 
    "src/test/java/com/bitplan/simplegraph/TestDebug.java" -> "src/test/java/com/bitplan/simplegraph" [ label="parent"]
 
    "src/main/java/com/bitplan/json/JsonPrettyPrinter.java" -> "src/main/java/com/bitplan/json" [ label="parent"]
 
    "src/etc" -> "src" [ label="parent"]
 
    "src/main/rythm/graphvizTree.rythm" -> "src/main/rythm" [ label="parent"]
 
    "src/test/java/com/bitplan/simplegraph/TestSuite.java" -> "src/test/java/com/bitplan/simplegraph" [ label="parent"]
 
    "src/main/java/com/bitplan/json/JsonSystem.java" -> "src/main/java/com/bitplan/json" [ label="parent"]
 
    "src/main" -> "src" [ label="parent"]
 
    "src/etc/header.txt" -> "src/etc" [ label="parent"]
 
    "src/main/java/com/bitplan/powerpoint/SlideShowNode.java" -> "src/main/java/com/bitplan/powerpoint" [ label="parent"]
 
    "src/test/employee.json" -> "src/test" [ label="parent"]
 
    "src/main/java" -> "src/main" [ label="parent"]
 
    "src/main/java/com/bitplan/powerpoint/SlideImage.java" -> "src/main/java/com/bitplan/powerpoint" [ label="parent"]
 
    "src/test/air-routes-small.graphml" -> "src/test" [ label="parent"]
 
    "src/main/rythm" -> "src/main" [ label="parent"]
 
    "src/main/java/com/bitplan/powerpoint/SlideShow.java" -> "src/main/java/com/bitplan/powerpoint" [ label="parent"]
 
    "src/test/resources" -> "src/test" [ label="parent"]
 
    "src/main/java/com" -> "src/main/java" [ label="parent"]
 
    "src/main/java/com/bitplan/powerpoint/SlideNode.java" -> "src/main/java/com/bitplan/powerpoint" [ label="parent"]
 
    "src/test/java" -> "src/test" [ label="parent"]
 
    "src/main/java/com/bitplan" -> "src/main/java/com" [ label="parent"]
 
    "src/main/java/com/bitplan/powerpoint/PowerPointSystem.java" -> "src/main/java/com/bitplan/powerpoint" [ label="parent"]
 
    "src/test/air-routes.graphml" -> "src/test" [ label="parent"]
 
    "src/main/java/com/bitplan/gremlin" -> "src/main/java/com/bitplan" [ label="parent"]
 
    "src/main/java/com/bitplan/powerpoint/Slide.java" -> "src/main/java/com/bitplan/powerpoint" [ label="parent"]
 
    "src/test/menu.json" -> "src/test" [ label="parent"]
 
    "src/main/java/com/bitplan/triplestore" -> "src/main/java/com/bitplan" [ label="parent"]
 
    "src/main/java/com/bitplan/simplegraph/impl" -> "src/main/java/com/bitplan/simplegraph" [ label="parent"]
 
    "src/test/pets.json" -> "src/test" [ label="parent"]
 
    "src/main/java/com/bitplan/filesystem" -> "src/main/java/com/bitplan" [ label="parent"]
 
    "src/main/java/com/bitplan/simplegraph/SimpleGraph.java" -> "src/main/java/com/bitplan/simplegraph" [ label="parent"]
 
    "src/test/resources/sidif" -> "src/test/resources" [ label="parent"]
 
    "src/main/java/com/bitplan/map" -> "src/main/java/com/bitplan" [ label="parent"]
 
    "src/main/java/com/bitplan/simplegraph/Keys.java" -> "src/main/java/com/bitplan/simplegraph" [ label="parent"]
 
    "src/test/resources/sidif/royal92.sidif" -> "src/test/resources/sidif" [ label="parent"]
 
    "src/main/java/com/bitplan/json" -> "src/main/java/com/bitplan" [ label="parent"]
 
    "src/main/java/com/bitplan/simplegraph/SimpleNode.java" -> "src/main/java/com/bitplan/simplegraph" [ label="parent"]
 
    "src/test/java/com" -> "src/test/java" [ label="parent"]
 
    "src/main/java/com/bitplan/powerpoint" -> "src/main/java/com/bitplan" [ label="parent"]
 
    "src/main/java/com/bitplan/simplegraph/SimpleSystem.java" -> "src/main/java/com/bitplan/simplegraph" [ label="parent"]
 
    "src/test/java/com/bitplan" -> "src/test/java/com" [ label="parent"]
 
    "src/main/java/com/bitplan/simplegraph" -> "src/main/java/com/bitplan" [ label="parent"]
 
    "src/main/java/com/bitplan/simplegraph/impl/Holder.java" -> "src/main/java/com/bitplan/simplegraph/impl" [ label="parent"]
 
    "src/test/java/com/bitplan/simplegraph" -> "src/test/java/com/bitplan" [ label="parent"]
 
    "src/main/java/com/bitplan/wikidata" -> "src/main/java/com/bitplan" [ label="parent"]
 
    "src/main/java/com/bitplan/simplegraph/impl/SimpleSystemImpl.java" -> "src/main/java/com/bitplan/simplegraph/impl" [ label="parent"]
 
    "src/test/java/com/bitplan/simplegraph/TestSMW.java" -> "src/test/java/com/bitplan/simplegraph" [ label="parent"]
 
    "src/main/java/com/bitplan/smw" -> "src/main/java/com/bitplan" [ label="parent"]
 
    "src/main/java/com/bitplan/simplegraph/impl/KeysImpl.java" -> "src/main/java/com/bitplan/simplegraph/impl" [ label="parent"]
 
    "src/test/java/com/bitplan/simplegraph/BaseTest.java" -> "src/test/java/com/bitplan/simplegraph" [ label="parent"]
 
    "src/main/java/com/bitplan/rythm" -> "src/main/java/com/bitplan" [ label="parent"]
 
    "src/main/java/com/bitplan/simplegraph/impl/SimpleNodeImpl.java" -> "src/main/java/com/bitplan/simplegraph/impl" [ label="parent"]
 
    "src/test/java/com/bitplan/simplegraph/TestMediaWiki.java" -> "src/test/java/com/bitplan/simplegraph" [ label="parent"]
 
    "src/main/java/com/bitplan/mediawiki" -> "src/main/java/com/bitplan" [ label="parent"]
 
    "src/main/java/com/bitplan/simplegraph/impl/Cache.java" -> "src/main/java/com/bitplan/simplegraph/impl" [ label="parent"]
 
    "src/test/java/com/bitplan/simplegraph/TestRythm.java" -> "src/test/java/com/bitplan/simplegraph" [ label="parent"]
 
    "src/main/java/com/bitplan/gremlin/RegexPredicate.java" -> "src/main/java/com/bitplan/gremlin" [ label="parent"]
 
    "src/main/java/com/bitplan/simplegraph/impl/SimpleGraphImpl.java" -> "src/main/java/com/bitplan/simplegraph/impl" [ label="parent"]
 
    "src/test/java/com/bitplan/simplegraph/TestWikiData.java" -> "src/test/java/com/bitplan/simplegraph" [ label="parent"]
 
    "src/main/java/com/bitplan/triplestore/TripleStoreSystem.java" -> "src/main/java/com/bitplan/triplestore" [ label="parent"]
 
    "src/main/java/com/bitplan/wikidata/WikiDataNode.java" -> "src/main/java/com/bitplan/wikidata" [ label="parent"]
 
    "src/test/java/com/bitplan/simplegraph/TestTinkerPop3.java" -> "src/test/java/com/bitplan/simplegraph" [ label="parent"]
 
    "src/main/java/com/bitplan/triplestore/TripleNode.java" -> "src/main/java/com/bitplan/triplestore" [ label="parent"]
 
    "src/main/java/com/bitplan/wikidata/WikiDataSystem.java" -> "src/main/java/com/bitplan/wikidata" [ label="parent"]
 
    "src/test/java/com/bitplan/simplegraph/TestFileSystem.java" -> "src/test/java/com/bitplan/simplegraph" [ label="parent"]
 
    "src/main/java/com/bitplan/filesystem/FileSystem.java" -> "src/main/java/com/bitplan/filesystem" [ label="parent"]
 
    "src/main/java/com/bitplan/smw/SMWSystem.java" -> "src/main/java/com/bitplan/smw" [ label="parent"]
 
    "src/test/java/com/bitplan/simplegraph/TestTripleStore.java" -> "src/test/java/com/bitplan/simplegraph" [ label="parent"]
 
    "src/main/java/com/bitplan/filesystem/FileNode.java" -> "src/main/java/com/bitplan/filesystem" [ label="parent"]
 
    "src/main/java/com/bitplan/rythm/RythmContext.java" -> "src/main/java/com/bitplan/rythm" [ label="parent"]
 
    "src/test/java/com/bitplan/simplegraph/TestPowerPoint.java" -> "src/test/java/com/bitplan/simplegraph" [ label="parent"]
 
    "src/main/java/com/bitplan/map/MapNode.java" -> "src/main/java/com/bitplan/map" [ label="parent"]
 
    "src/main/java/com/bitplan/mediawiki/MediaWikiPageNode.java" -> "src/main/java/com/bitplan/mediawiki" [ label="parent"]
 
  }
 
</graphviz>
 
== 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:
 
<source lang='java'>
 
// 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);
 
</source>
 
=== converting the graph to graphviz ===
 
The graph is now available and can be traversed to create a graphviz version of it. We use
 
the {{Link|target=Rythm}} template engine to do so. Within Rythm you can use Java code.
 
Basically we try out the code in the
 
[https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/test/java/com/bitplan/simplegraph/TestRythm.java TestRythm JUnit test] and then use it in the Rythm template
 
[https://github.com/BITPlan/com.bitplan.simplegraph/blob/master/src/main/rythm/graphvizTree.rythm graphvizTree.rythm]
 
  
 
= MapSystem example =
 
= MapSystem example =

Revision as of 12:38, 13 February 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.

Modules

  1. SimpleGraph-FileSystem


MapSystem example

The MapSystem is a simple wrapper for a graph with nodes that have key/value pairs. We would not really need this since Apache Tinkerpop/Gremlin already supplies us with properties per node/vertex. Still this system is useful as a helper system and to illustrate the wrapping concepts and possibilities of SimpleGraph

Unit Test

  @Test
  public void testMapSystem() throws Exception {
    // create a map system and connect to init
    MapSystem ms=new MapSystem();
    ms.connect();
    // init some maps of carbrands and cars each map shall later represent a
    // vertex in the graph with it's properties
    Map[] carbrandmaps= {
        initMap("name","Ferrari","country","Italy","wikidataid","Q27586"),
        initMap("name","Porsche","country","Germany","wikidataid","Q40993"),
        initMap("name","Ford","cuntry","United States","wikidataid","Q44294")
    };
    Map[] carmakemaps= {
        initMap("name","308","year",1984,"wikidataid","Q1407659","brand","Ferrari"),
        initMap("name","328","year",1989,"wikidataid","Q1407669","brand","Ferrari"),
        initMap("name","901","year",1964,"wikidataid","Q2104537","brand","Porsche"),
        initMap("name","2017 GT","year",2017,"wikidataid","Q23856323","brand","Ford")
    };
    // create MapNodes with the given kind "carbrand" or "car" based on the maps
    MapNode startNode=null;
    for (Map map:carbrandmaps) {
      startNode=new MapNode(ms,"carbrand",map);
    }
    for (Map map:carmakemaps) {
      MapNode mapNode=new MapNode(ms,"car",map);
      // link the node of this car to it's carbrand node using the Gremlin graph traversal
      // language - this is the key action for this example
      ms.g().V().hasLabel("carbrand").has("name",map.get("brand")).forEachRemaining(brandNode->{
        brandNode.addEdge("brand", mapNode.getVertex());
      });
    }
    // set a start node for the system
    // any node will do and for this example it is not really necessary - each node
    // has the full graph accesible
    ms.setStartNode(startNode);
    // uncomment if you'd like to see all the node details
    // debug=true;
    if (debug)
      ms.g().V().forEachRemaining(SimpleNode.printDebug);
    // generate a graphviz graph based on this start node
    // show the "brand" edges
    // show the "name" for each node
    // use wikidataid as the identifier
    // and extend to a full url using the WIKIDATA_URL_PREFIX
    // use the rankDir RL = right left
    // and name the graph "CarGraph"
    String graphViz = TestRythm.generateGraphViz(ms.getStartNode(), "brand", "name", "wikidataid",
        WIKIDATA_URL_PREFIX,"RL","CarGraph");
    // uncomment if you'd like to see the graph source code
    // the rendered graph is available at http://www.bitplan.com/index.php?title=SimpleGraph#CarGraph
    // debug = true;
    if (debug)
      System.out.println(graphViz.trim());
    // check that the graph contains one of the expected graphviz code lines
    assertTrue(graphViz.contains("\"Q27586\" [ label=\"Ferrari\" URL=\"https://www.wikidata.org/wiki/Q27586\"]"));
  }

CarGraph

The nodes of this graph are clickable and will lead you to the wikidata pages of the cars and carbrands.


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