项目作者: lant

项目描述 :
JVM dot graph file output
高级语言: Java
项目地址: git://github.com/lant/dotdump.git
创建时间: 2017-06-20T07:01:36Z
项目社区:https://github.com/lant/dotdump

开源协议:MIT License

下载


DotDump, a JVM .dot file generating library.

DotDump aims to be a very simple dot graph file format output for the JVM.

I found myself writing different hacky dot file dumpers for different projects, so I decided that I’d write a fairly decent one once and for all.

This library 100% java without external dependencies (other than junit) is thread safe.

This is not a graph library, it just writes your graph into dot format.

You can find more info about the dot format at Graphviz web

Build Status
License MIT
Maven Central

Examples

A simple music chart:

  1. import com.github.lant.dotdump.*;
  2. import java.io.File;
  3. import java.io.IOException;
  4. class Example {
  5. public static void main(String ...args) throws IOException {
  6. Dot musicGraph = new Dot(GraphType.DIGRAPH, "Some metal bands");
  7. musicGraph.withComment("Some metal bands to draw a graph");
  8. GraphNode maiden = new GraphNode("iron-maiden").withText("Iron Maiden").withShape(NodeShapes.box);
  9. GraphNode sabbath = new GraphNode("b-sabbath").withText("Black Sabbath").withShape(NodeShapes.circle);
  10. GraphNode acdc = new GraphNode("acdc").withText("AC-DC").withShape(NodeShapes.diamond);
  11. GraphNode mayhem = new GraphNode("mayhem").withText("Mayhem").withShape(NodeShapes.ellipse);
  12. GraphNode venom = new GraphNode("venom").withText("Venom").withShape(NodeShapes.house);
  13. GraphNode nasum = new GraphNode("nasum").withText("Nasum").withShape(NodeShapes.lpromoter);
  14. GraphNode slayer = new GraphNode("slayer").withText("Slayer").withShape(NodeShapes.box3d);
  15. musicGraph.withNode(maiden);
  16. musicGraph.withNode(sabbath);
  17. musicGraph.withNode(acdc);
  18. musicGraph.withNode(mayhem);
  19. musicGraph.withNode(venom);
  20. musicGraph.withNode(nasum);
  21. musicGraph.withNode(slayer);
  22. musicGraph.withRelation(new NodeRelation(acdc, maiden).withLabel("Influenced"));
  23. musicGraph.withRelation(new NodeRelation(sabbath, maiden).withLabel("Influenced"));
  24. musicGraph.withRelation(new NodeRelation(slayer, venom).withLabel("Influenced"));
  25. musicGraph.withRelation(new NodeRelation(venom, mayhem).withLabel("Influenced"));
  26. musicGraph.withRelation(new NodeRelation(sabbath, slayer).withLabel("Influenced"));
  27. musicGraph.withRelation(new NodeRelation(slayer, nasum).withLabel("Influenced"));
  28. musicGraph.writeToFile(new File("music.dot"));
  29. }
  30. }

That will generate this dot file:

  1. DIGRAPH "Some metal bands" {
  2. # Some metal bands to draw a graph
  3. "iron-maiden" [label="Iron Maiden", shape=box];
  4. "b-sabbath" [label="Black Sabbath", shape=circle];
  5. "acdc" [label="AC-DC", shape=diamond];
  6. "mayhem" [label="Mayhem", shape=ellipse];
  7. "venom" [label="Venom", shape=house];
  8. "nasum" [label="Nasum", shape=lpromoter];
  9. "slayer" [label="Slayer", shape=box3d];
  10. "acdc" -> "iron-maiden"[label="Influenced"];
  11. "b-sabbath" -> "iron-maiden"[label="Influenced"];
  12. "slayer" -> "venom"[label="Influenced"];
  13. "venom" -> "mayhem"[label="Influenced"];
  14. "b-sabbath" -> "slayer"[label="Influenced"];
  15. "slayer" -> "nasum"[label="Influenced"];
  16. }

Changelog

0.5

  • Gradle to 5.X
  • Edges have optional weights

0.4

  • Release ready.

0.3

  • Packaging to maven repository.
  • Thread safe.

0.2

  • Tested with files.
  • Colors

0.1

  • Basic functionality to draw graphs and digraphs.
  • Node shapes and labels.