Representing Graphs

Example 1:

1 First node
2 Second node
#
1 2 Edge between the two

Example 2:

0 "Door" type=object
1 "Open" type=state
2 "Closed" type=state
3 "Opening" type=process
4 "Closing" type=process
#
0 1 "has state"
0 2 "has state"
3 0 "changes"
3 1 "to state"
4 0 "changes"
4 2 "to state"

src: https://github.com/fedwiki/wiki/issues/63

Example 3:

[tgf engine:graphapi_png
PRD
ACC
TST
DEV
git
#
PRD PRD dbupdate, migrate, backup, restore
PRD ACC sync
ACC git pull
DEV git commit, push
TST git pull
PRD TST sync
TST PRD sync
PRD git pull
]

src: http://build2be.com/content/just-trivial-graph

2. Newick format

Example 1:

(,,(,));                               no nodes are named
(A,B,(C,D)); leaf nodes are named
(A,B,(C,D)E)F; all nodes are named
(:0.1,:0.2,(:0.3,:0.4):0.5); all but root node have a distance to parent
(:0.1,:0.2,(:0.3,:0.4):0.5):0.0; all have a distance to parent
(A:0.1,B:0.2,(C:0.3,D:0.4):0.5); distances and leaf names (popular)
(A:0.1,B:0.2,(C:0.3,D:0.4)E:0.5)F; distances and all names
((B:0.2,(C:0.3,D:0.4)E:0.5)F:0.1)A; a tree rooted on a leaf node (rare)

Example 2:

(((a,c),b),((d,e),(f,g)))

src: http://rosalind.info/glossary/newick-format/

Example 3:

(A(B(C,D(E))F(G,H)));

src: http://wiki.christophchamp.com/index.php?title=Newick_phylogenetic_tree_format

3. GraphML

Example 1:

src: https://cs.brown.edu/~rt/gdhandbook/chapters/graphml.pdf

4. GML & XGMML

src: http://cgi7.cs.rpi.edu/research/groups/pb/punin/public_html/XGMML/draft-xgmml.html

5. DGML

<?xml version='1.0' encoding='utf-8'?>
<DirectedGraph xmlns="http://schemas.microsoft.com/vs/2009/dgml">
<Nodes>
<Node Id="a" Label="a" Size="10" />
<Node Id="b" Background="#FF008080" Label="b" />
<Node Id="c" Label="c" Start="2010-06-10" />
</Nodes>
<Links>
<Link Source="a" Target="b" />
<Link Source="a" Target="c" />
</Links>
<Properties>
<Property Id="Background" Label="Background" DataType="Brush" />
<Property Id="Label" Label="Label" DataType="String" />
<Property Id="Size" DataType="String" />
<Property Id="Start" DataType="DateTime" />
</Properties>
</DirectedGraph>

src: https://en.wikipedia.org/wiki/DGML

6. DOT / Graphviz

Example 1:

graph graphname {
a -- b -- c;
b -- d;
}
digraph g {
node [shape=plaintext];
A1 -> B1;
A2 -> B2;
A3 -> B3;

A1 -> A2 [label=f];
A2 -> A3 [label=g];
B2 -> B3 [label="g'"];
B1 -> B3 [label="(g o f)'" tailport=s headport=s];

{ rank=same; A1 A2 A3 }
{ rank=same; B1 B2 B3 }
}

src: https://en.wikipedia.org/wiki/DOT_(graph_description_language)

Example 2:

src: http://graphs.grevian.org/example

Example 3:

src: http://note.yuhc.me/2014/12/dot-and-graphviz/

7. TikZ

Example 1:

% Drawing a graph using the PG 3.0 graphdrawing library
% Author: Mark Wibrow
\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{graphdrawing}
\usetikzlibrary{graphs}
\usegdlibrary{trees}
\begin{document}
\begin{tikzpicture}[>=stealth, every node/.style={circle, draw, minimum size=0.75cm}]
\graph [tree layout, grow=down, fresh nodes, level distance=0.5in, sibling distance=0.5in]
{
4 -> {
3 -> { 1 -> { 5, " " }, 2,2 },
3 -> { 1, 2, 2 },
3 -> { 1, 2, 2 }
}
};
\end{tikzpicture}
\end{document}
% Author: Till Tantau
% Source: The PGF/TikZ manual

\documentclass{article}

\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows,automata}
\usepackage[latin1]{inputenc}
\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm,
semithick]
\tikzstyle{every state}=[fill=red,draw=none,text=white]

\node[initial,state] (A) {$q_a$};
\node[state] (B) [above right of=A] {$q_b$};
\node[state] (D) [below right of=A] {$q_d$};
\node[state] (C) [below right of=B] {$q_c$};
\node[state] (E) [below of=D] {$q_e$};

\path (A) edge node {0,1,L} (B)
edge node {1,1,R} (C)
(B) edge [loop above] node {1,1,L} (B)
edge node {0,1,L} (C)
(C) edge node {0,1,L} (D)
edge [bend left] node {1,0,R} (E)
(D) edge [loop below] node {1,1,R} (D)
edge node {0,1,R} (A)
(E) edge [bend left] node {1,0,R} (A);
\end{tikzpicture}
\end{document}

src: http://www.texample.net/tikz/examples/tag/graphs/

8. Adjacency …

Adjacency Matrix, Edge List, Neighbor List, Paths

src: http://www.thecrazyprogrammer.com/2014/03/representation-of-graphs-adjacency-matrix-and-adjacency-list.html

9. Expressions

src: http://users.ece.gatech.edu/limsk/course/ece6133/slides/floorplanning.pdf

====

Misc sources:

 by the author.

--

--

--

https://alexadam.dev/

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
alex adam

alex adam

https://alexadam.dev/

More from Medium

Semiconductor and People (part 2.)

Creation of a digital twin of the Kaluga trolleybus

Visualizing Poetry using DALL-E

Knight’s Yarn