# graph-support
**Repository Path**: binbingeng/graph-support
## Basic Information
- **Project Name**: graph-support
- **Description**: java的节点连线图的支持库
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 1
- **Created**: 2022-07-14
- **Last Updated**: 2022-07-14
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# graph-support
#### introduce
The ultimate goal of graph-support is to implement a pure Java implementation of [graphviz](https://gitlab.com/graphviz/graphviz/) .This means that there is no need to install Graphviz on the computer, and there is no need to rely on a V8 javascript engine like [graphviz-java](https://github.com/nidi3/graphviz-java), which is very convenient and efficient to use .
**builder style api**
```java
// initialize node
Node n_ksh = Node.builder().label("ksh").style(NodeStyle.DASHED).build();
Node n_System_V = Node.builder().label("System_V").color(Color.RED).build();
Node n_vsh = Node.builder().label("vsh").fontSize(36).build();
Node n_Mashey = Node.builder().label("Mashey").style(NodeStyle.FILLED).fillColor(Color.GREEN).build();
Node n_ksh_POSIX = Node.builder().label("ksh_POSIX").build();
Node n_Thompson = Node.builder().label("Thompson").build();
Node n_ks_i = Node.builder().label("ks_i").style(NodeStyle.BOLD).build();
Node n_Formshell = Node.builder().label("Formshell").build();
Node n_Bash = Node.builder().label("Bash").build();
Node n_v9sh = Node.builder().label("v9sh").build();
Node n_POSIX = Node.builder().label("POSIX").build();
Node n_rc = Node.builder().label("rc").build();
Node n_tcsh = Node.builder().label("tcsh").build();
Node n_Bourne = Node.builder().label("Bourne").style(NodeStyle.DASHED).fillColor(Color.GOLD).build();
Node n_csh = Node.builder().label("csh").build();
Node n_esh = Node.builder().label("esh").build();
Node n_KornShell = Node.builder().label("KornShell").build();
Graphviz graphviz = Graphviz
.digraph()
.scale(0.75)
.tempNode(
Node.builder().color(Color.BLACK).build()
)
.addLine(n_Thompson, n_Mashey)
.addLine(n_Thompson, n_Bourne)
.addLine(n_Thompson, n_csh)
.addLine(n_Bourne, n_Formshell)
.addLine(n_Bourne, n_esh)
.addLine(n_Bourne, n_vsh)
.addLine(n_Bourne, n_v9sh)
.addLine(Line.builder(n_Bourne, n_ksh).label("Bourne --> ksh").build())
.addLine(n_Bourne, n_System_V)
.addLine(n_csh, n_ksh)
.addLine(n_csh, n_tcsh)
.addLine(n_esh, n_ksh)
.addLine(n_vsh, n_ksh)
.addLine(n_Formshell, n_ksh)
.addLine(n_v9sh, n_rc)
.addLine(n_ksh, n_ks_i)
.addLine(n_ks_i, n_KornShell)
.addLine(n_ks_i, n_Bash)
.addLine(n_Bourne, n_Bash)
.addLine(n_KornShell, n_ksh_POSIX)
.addLine(n_KornShell, n_Bash)
.addLine(n_KornShell, n_POSIX)
.addLine(n_System_V, n_POSIX)
.build();
// Svg render
RenderEngine renderEngine = SvgRenderEngine.getInstance();
GraphResource graphResource = renderEngine.render(graphviz);
System.out.println(graphResource.content());
```
**dot rendering effect**

```java
Node Thompson = Node.builder().label("Thompson").build();
Node Bourne = Node.builder().label("Bourne").build();
Node Mashey = Node.builder().label("Mashey").build();
Node Formshell = Node.builder().label("Formshell").build();
Node csh = Node.builder().label("csh").build();
Node esh = Node.builder().label("esh").build();
Node vsh = Node.builder().label("vsh").build();
Node ksh = Node.builder().label("ksh").build();
Node System_V = Node.builder().label("System-V").build();
Node v9sh = Node.builder().label("v9sh").build();
Node tcsh = Node.builder().label("tcsh").build();
Node ks_i = Node.builder().label("ksh-i").build();
Node rc = Node.builder().label("rc").build();
Node KornShell = Node.builder().label("KornShell").build();
Node Bash = Node.builder().label("Bash").build();
Node ksh_POSIX = Node.builder().label("ksh-POSIX").build();
Node POSIX = Node.builder().label("POSIX").build();
Node Perl = Node.builder().label("Perl").build();
Node tcl = Node.builder().label("tcl").build();
Node n_1972 = Node.builder().label("1972").build();
Node n_1976 = Node.builder().label("1976").build();
Node n_1978 = Node.builder().label("1978").build();
Node n_1980 = Node.builder().label("1980").build();
Node n_1982 = Node.builder().label("1982").build();
Node n_1984 = Node.builder().label("1984").build();
Node n_1986 = Node.builder().label("1986").build();
Node n_1988 = Node.builder().label("1988").build();
Node n_1990 = Node.builder().label("1990").build();
Node n_future = Node.builder().label("future").build();
Graphviz graphviz = Graphviz
.digraph()
.scale(0.6)
.tempLine(Line.builder(Thompson, Thompson).minlen(1).build())
.addLine(Line.builder(Thompson, Mashey).build())
.addLine(Line.builder(Thompson, Bourne).build())
.addLine(Line.builder(Thompson, csh).build())
.addLine(Line.builder(Bourne, Formshell).build())
.addLine(Line.builder(Bourne, esh).build())
.addLine(Line.builder(Bourne, vsh).build())
.addLine(Line.builder(Bourne, v9sh).build())
.addLine(Line.builder(Bourne, ksh).build())
.addLine(Line.builder(Bourne, System_V).build())
.addLine(Line.builder(csh, ksh).build())
.addLine(Line.builder(csh, tcsh).build())
.addLine(Line.builder(esh, ksh).build())
.addLine(Line.builder(vsh, ksh).build())
.addLine(Line.builder(Formshell, ksh).build())
.addLine(Line.builder(v9sh, rc).build())
.addLine(Line.builder(ksh, ks_i).build())
.addLine(Line.builder(ks_i, KornShell).build())
.addLine(Line.builder(ks_i, Bash).build())
.addLine(Line.builder(Bourne, Bash).build())
.addLine(Line.builder(KornShell, Bash).build())
.addLine(Line.builder(KornShell, ksh_POSIX).build())
.addLine(Line.builder(KornShell, POSIX).build())
.addLine(Line.builder(System_V, POSIX).build())
.tempNode(Node.builder().shape(NodeShape.PLANTEXT).build())
.tempLine(Line.tempLine().weight(5).build())
.addLine(n_1972, n_1976)
.addLine(n_1976, n_1978)
.addLine(n_1978, n_1980)
.addLine(n_1980, n_1982)
.addLine(n_1982, n_1984)
.addLine(n_1984, n_1986)
.addLine(n_1986, n_1988)
.addLine(n_1988, n_1990)
.addLine(n_1990, n_future)
.subgraph(
Subgraph.builder()
.rank(Rank.SAME)
.addNode(n_1972)
.addNode(Thompson)
.build()
)
.subgraph(
Subgraph.builder()
.rank(Rank.SAME)
.addNode(n_1976)
.addNode(Mashey)
.addNode(Bourne)
.build()
)
.subgraph(
Subgraph.builder()
.rank(Rank.SAME)
.addNode(n_1978)
.addNode(Formshell)
.addNode(csh)
.build()
)
.subgraph(
Subgraph.builder()
.rank(Rank.SAME)
.addNode(n_1980)
.addNode(esh)
.addNode(vsh)
.build()
)
.subgraph(
Subgraph.builder()
.rank(Rank.SAME)
.addNode(n_1982)
.addNode(ksh)
.addNode(System_V)
.build()
)
.subgraph(
Subgraph.builder()
.rank(Rank.SAME)
.addNode(n_1984)
.addNode(v9sh)
.addNode(tcsh)
.build()
)
.subgraph(
Subgraph.builder()
.rank(Rank.SAME)
.addNode(n_1986)
.addNode(ks_i)
.build()
)
.subgraph(
Subgraph.builder()
.rank(Rank.SAME)
.addNode(n_1988)
.addNode(KornShell)
.addNode(Perl)
.addNode(rc)
.build()
)
.subgraph(
Subgraph.builder()
.rank(Rank.SAME)
.addNode(n_1990)
.addNode(tcl)
.addNode(Bash)
.build()
)
.subgraph(
Subgraph.builder()
.rank(Rank.SAME)
.addNode(n_future)
.addNode(POSIX)
.addNode(ksh_POSIX)
.build()
)
.tempLine(Line.tempLine().style(LineStyle.INVIS).build())
.addLine(n_1982, System_V)
.addLine(n_1984, v9sh)
.addLine(v9sh, tcsh)
.addLine(n_1988, rc)
.addLine(rc, KornShell)
.addLine(Formshell, csh)
.addLine(KornShell, Perl)
.addLine(n_1990, tcl)
.build();
// Svg render
RenderEngine renderEngine = SvgRenderEngine.getInstance();
GraphResource graphResource = renderEngine.render(graphviz);
System.out.println(graphResource.content());
```
