wolffd@0
|
1 <h1>Visualizing graph structures in matlab</h1>
|
wolffd@0
|
2
|
wolffd@0
|
3 We discuss some methods for visualizing graphs/ networks, including automatic
|
wolffd@0
|
4 layout of the nodes.
|
wolffd@0
|
5 We assume the graph is represented as an adjacency matrix.
|
wolffd@0
|
6 If using BNT, you can access the DAG using
|
wolffd@0
|
7 <pre>
|
wolffd@0
|
8 G = bnet.dag;
|
wolffd@0
|
9 </pre>
|
wolffd@0
|
10
|
wolffd@0
|
11 <h2>Matlab's biograph function</h2>
|
wolffd@0
|
12
|
wolffd@0
|
13 The Mathworks computational biology toolbox
|
wolffd@0
|
14 has many useful graph related functions, including visualization.
|
wolffd@0
|
15 <br>
|
wolffd@0
|
16 Click
|
wolffd@0
|
17 <a href="http://www.mathworks.com/products/bioinfo/demos.html?file=/products/demos/shipping/bioinfo/graphtheorydemo.html#4">
|
wolffd@0
|
18 here</a>
|
wolffd@0
|
19 for a demo.
|
wolffd@0
|
20
|
wolffd@0
|
21
|
wolffd@0
|
22
|
wolffd@0
|
23 <h2>Cemgil's draw_graph</h2>
|
wolffd@0
|
24
|
wolffd@0
|
25 You can visualize an arbitrary graph (such as one learned using the
|
wolffd@0
|
26 structure learning routines) with Matlab code written by
|
wolffd@0
|
27 <a href="http://www-sigproc.eng.cam.ac.uk/~atc27/matlab/layout.html">
|
wolffd@0
|
28 Ali Taylan Cemgil</a>
|
wolffd@0
|
29 from the University of Cambridge.
|
wolffd@0
|
30 A modified version of this code
|
wolffd@0
|
31 is <a href="GraphViz.zip">here</a>
|
wolffd@0
|
32 (this is already bundled with BNT).
|
wolffd@0
|
33 Just type
|
wolffd@0
|
34 <pre>
|
wolffd@0
|
35 draw_graph(G);
|
wolffd@0
|
36 </pre>
|
wolffd@0
|
37 For example, this is the output produced on a
|
wolffd@0
|
38 <a href="http://www.cs.ubc.ca/~murphyk/Software/BNT/usage.html#qmr">random QMR-like model</a>:
|
wolffd@0
|
39 <p>
|
wolffd@0
|
40 <img src="Figures/qmr.rnd.jpg">
|
wolffd@0
|
41 <p>
|
wolffd@0
|
42
|
wolffd@0
|
43 <h2>Pajek</h2>
|
wolffd@0
|
44
|
wolffd@0
|
45 <a href="http://vlado.fmf.uni-lj.si/pub/networks/pajek">Pajek</a>
|
wolffd@0
|
46 is an excellent, free Windows program for graph layout.
|
wolffd@0
|
47 Use <a href="adj2pajek2.m">adj2pajek2.m</a> to convert a graph to the
|
wolffd@0
|
48 Pajek file format.
|
wolffd@0
|
49 <br>
|
wolffd@0
|
50 Then Choose File->Network->Read from the menu.
|
wolffd@0
|
51
|
wolffd@0
|
52 <h2>AT&T Graphviz</h2>
|
wolffd@0
|
53
|
wolffd@0
|
54 <a href="http://www.research.att.com/sw/tools/graphviz">graphhviz</a>
|
wolffd@0
|
55 is an
|
wolffd@0
|
56 open-source graph visualization package from AT&T.
|
wolffd@0
|
57 Use
|
wolffd@0
|
58 <a href="graph_to_dot.m">graph_to_dot</a>
|
wolffd@0
|
59 to convert an adjacency matrix to
|
wolffd@0
|
60 the AT&T file format (the "dot" format).
|
wolffd@0
|
61 You then use dot to convert it to postscript:
|
wolffd@0
|
62 <pre>
|
wolffd@0
|
63 graph_to_dot(G, 'filename', 'foo.dot');
|
wolffd@0
|
64 dot -Tps foo.dot -o foo.ps
|
wolffd@0
|
65 ghostview foo.ps &
|
wolffd@0
|
66 </pre>
|