Mercurial > hg > graphML2RDF
comparison dottoxml/doc/index.wiki @ 4:4fa7bf58e914
first release
author | dwinter |
---|---|
date | Mon, 23 Jul 2012 09:58:50 +0200 |
parents | d5de1d6e9338 |
children |
comparison
equal
deleted
inserted
replaced
3:c97d43ac8fa6 | 4:4fa7bf58e914 |
---|---|
1 @title: dottoxml | |
2 @author: Dirk Baechle | |
3 | |
4 While trying to get a deeper understanding for the source of the build | |
5 system [[http://www.scons.org SCons]], I actually wanted to see the classes | |
6 and their dependencies. Googling around I found these two tools that could | |
7 produce DOT graph files for class or import dependencies from Python source trees. | |
8 | |
9 ~[[http://furius.ca/snakefood snakefood]]||Creates module import dependency graphs. Use the Mercurial command %%hg clone https://hg.furius.ca/public/snakefood%% for a checkout of the current sources. | |
10 ~[[http://www.logilab.org/project/pylint pyreverse]]||As part of pylint it analyzes class dependencies. | |
11 | |
12 Unfortunately, the resulting graphs were pretty large and visualizing them via | |
13 the $$dot$$ tool did not help. PNG, PS or SVG output, the images got too large and | |
14 the layout of the nodes and edges left a lot to desire (Example: SCons dependencies | |
15 in [[scons.ps Postscript]] and [[scons.svg SVG]] format). | |
16 | |
17 Then I remembered the [[http://www.yworks.com/en/products_yed_about.html yEd graph editor]], a | |
18 great application that can layout and handle even very large datasets...if you find a | |
19 way to get the data inside. Since it does not import DOT files (yet), I wrote this | |
20 little converter script that outputs yEd's native file format Graphml (XML). | |
21 | |
22 Now looking at complicated DOT graphs is a snap...have a try! | |
23 | |
24 | |
25 == Current version == current | |
26 | |
27 ~[[dottoxml.zip dottoxml.zip]]||Archived folder with the Python scripts for $$dottoxml$$. | |
28 | |
29 == Contributions == contrib | |
30 | |
31 ~2010-11-13||Daniel Reynaud: error report and patch (copying of attributes for default nodes and edges did not work, due to a copy-paste error). | |
32 ~2010-01-27||Martin Bijl-Schwab: error report and patch ($$self.sections$$ did not get initialized in all cases). | |
33 | |
34 == Basic usage == basic | |
35 | |
36 Note: | |
37 The following screenshots are not from a dependency analysis but a profiling | |
38 of [[http://scons.tigris.org SCons]] at runtime. Using a combination of | |
39 [[http://code.google.com/p/jrfonseca/wiki/Gprof2Dot $$Gprof2Dot$$]] and [[http://www.graphviz.org Graphviz DOT]], | |
40 Nitro Zark has published the results of his investigations on | |
41 [[http://nitrozark.free.fr/scons/bench1/benchmark-gfw-20090702.html his webpage]]. I picked the file $$benchgen-full-dry-run.dot$$ | |
42 because it uses colors to a great extent, which gives a nice looking graph. | |
43 | |
44 Start the script with the ''-h'' or ''--help'' option and the | |
45 full set of available commands is displayed. | |
46 | |
47 The straightforward way to create a Graphml file out of a DOT is: | |
48 | |
49 Code: | |
50 python dottoxml.py infile.dot outfile.graphml | |
51 | |
52 Then open the new Graphml file in the [[http://www.yworks.com/en/products_yed_about.html yEd editor]]. The nodes of the | |
53 graph are now all centered to the origin and have a standard size of | |
54 30x30. | |
55 | |
56 [[yed1.png <<yed1.png||alt="Centered nodes" width="100%">>]] | |
57 | |
58 Change the latter by using the ''Tools'' menu in yEd and select the | |
59 entry ''Fit Nodes to Label''. This feature adapts the size of each node | |
60 to the text that is displayed within. | |
61 | |
62 [[yed1.png <<yed2.png||alt="Fitted nodes" width="100%">>]] | |
63 | |
64 Now you can select one of the automatic layout strategies from the ''Layout'' | |
65 menu. Often, one or two dialogs with special options appear. | |
66 | |
67 [[yed3.png <<yed3.png||alt="Options dialog" width="100%">>]] | |
68 | |
69 Just go | |
70 with the default settings and click OK. The nodes in the graph are then | |
71 rearranged, according to your selected strategy. Here we see the | |
72 layout ''Hierarchical, classic'': | |
73 | |
74 [[yed4.png <<yed4.png||alt="Full graph" width="100%">>]] | |
75 | |
76 And another time, in a randomly chosen closeup: | |
77 | |
78 [[yed5.png <<yed5.png||alt="Closeup" width="100%">>]] | |
79 | |
80 For further advice about the display or editing of graphs in [[http://www.yworks.com/en/products_yed_about.html yEd]], | |
81 refer to its manual please. | |
82 | |
83 == Color options == colors | |
84 | |
85 In the screenshots above, the nodes are colored because the DOT file contained the necessary | |
86 attribute statements. The $$dottoxml$$ script tries to pick up as much information as possible from the | |
87 input file, not only colors but also arrow shapes (''arrow'' vs. ''diamond'') for example. | |
88 | |
89 If no color information is present in the DOT file, $$dottoxml$$ falls back to its defaults | |
90 which are: some sort of grey (#CCCCFF) for the node background, and black (#000000) for the outline, | |
91 the labels and the arrows. | |
92 | |
93 [[yed6.png <<yed6.png||alt="Default colors" width="100%">>]] | |
94 | |
95 You can override the default colors with the four commandline options: | |
96 | |
97 ~$$--cn$$|| Node background color | |
98 ~$$--ce$$|| Edge color | |
99 ~$$--cnt$$|| Node label color | |
100 ~$$--cet$$|| Edge label color | |
101 | |
102 An example: | |
103 | |
104 Code: | |
105 python dottoxml.py --cn #FF0000 infile.dot outfile.graphml | |
106 | |
107 sets the standard node background to a pure ''red''. Instead of | |
108 giving RGB triplets, you can also specify an X11 color name like this: | |
109 | |
110 Code: | |
111 python dottoxml.py --cn blanchedalmond infile.dot outfile.graphml | |
112 | |
113 [[yed7.png <<yed7.png||alt="Blanched almond" width="100%">>]] | |
114 | |
115 == Other specials == specials | |
116 | |
117 Very simple graphs often contain only the node labels and the edge information | |
118 itself, but no labels for the edges. With the option ''$$--ae$$'' you can enable | |
119 the ''Auto labeling''. This means that for every edge that does not provide its | |
120 own label, $$dottoxml$$ generates one of the form | |
121 | |
122 Code: | |
123 source_node_label -> destination_node_label | |
124 | |
125 When analyzing dependencies, there may appear single nodes that are ''isolated'' | |
126 from the rest of the graph and have no outgoing or incoming edges at all. | |
127 If you want to see only ''connected'' nodes, you can enable the ''sweep'' option ''$$-s$$''. | |
128 The script then filters out all single nodes and does not output them to the Graphml file. | |
129 | |
130 Finally, a very special option for the work with UML nodes that also contain the names | |
131 of attributes and methods for a class. If you activate the ''Fit Label to Nodes'' feature | |
132 in yEd, the nodes are expanded only around the class name (=label) but not the methods. | |
133 As a workaround you can enable the ''lumping attributes'' option ''$$--la$$'', which | |
134 collects all the text data for the UML node and puts it into the label. The single | |
135 sections are divided by separators, built with the ''separator char'' given by the ''$$--sc$$'' | |
136 option. | |
137 | |
138 == Restrictions == restrict | |
139 | |
140 This script is still under development and far from stable! Please note the following | |
141 remarks and restrictions: | |
142 | |
143 #At the moment, the DOT parser is very simple and line-based. It detects only node and | |
144 edge lines, no subgraphs are handled. Node and edge specifications must be in a single | |
145 line! | |
146 #I tried to do my best, but the whole encoding part (Unicode support and detection of | |
147 input encoding) still appears to be a little bit ''shaky'' to me. Do not expect too much | |
148 here. | |
149 | |
150 == More examples == more | |
151 | |
152 More examples and screenshots can be found at the [[http://scons.org/wiki/VisualizeDependencies VisualizeDependencies]] page in the | |
153 [[http://scons.org/wiki SCons Wiki]]... | |
154 |