[VTK ARB] Dependency generations and visualisation - take 2

Andrew Maclean a.maclean at cas.edu.au
Sun Aug 22 18:28:15 EDT 2010


Hi Jeff,
   This extends your idea of looking at the includes, by allowing the
user to specify a particular class and (optionally) restrict the depth
of the subsequent tree.

You can select a particular class and view all the includes for that
class. Optionally you can control the depth of the tree and create an
output suitable for graphviz. To do this, use get_subgraph.py and run it
using vtkdepends.py as input.

python depends.py > vtkdepends.txt

Here we select a particular class (vtkParametricTorus), the topmost two
levels of the tree and format for subsequent use by graphviz.
python get_subgraph.py -i vtkdepends.txt -c vtkParametricTorus -g -d 2 >
x
dot -Tps -O x

Here we select a particular class (vtkParametricTorus), all levels of
the tree and run it dependsview.py.
python get_subgraph.py -i vtkdepends.txt -c vtkParametricTorus > x
vtkpython dependsview.py x



One issue I have is that I get a segfault if I restrich the depth of the
tree output and run dependsview.py.
e.g
python get_subgraph.py -i vtkdepends.txt -c vtkParametricTorus -d 2 > x
vtkpython dependsview.py x

Produces this output:
Total number of classes:  5
Top Ten:
 18
vtkMath 7
vtkObjectFactory 7
vtkParametricTorus 3
vtkParametricFunction 1
 0
Segmentation fault


Regards
   Andrew



On Thu, 2010-08-19 at 11:43 -0400, Jeff Baumes wrote:
> I attempted some custom scripts to see the include structure of VTK.
> 
> 
> python depends.py > vtkdepends.txt
> vtkpython dependsview.py vtkdepends.txt
> 
> 
> The first will create a two-column list of all includes from one class
> to another in VTK and must be called from the root of VTK source. The
> second visualizes the data with VTK itself and prints out the classes
> with the highest number of connections. Since the network makes a
> so-called "hairball", the second script optionally takes a maximum
> linkage cutoff to simplify the graph, e.g.
> 
> 
> vtkpython dependsview.py vtkdepends.txt 10
> 
> 
> will remove any classes with more than 10 links. Nodes are colored by
> number of connections.
> 
> 
> Jeff
> 
> On Wed, Aug 18, 2010 at 10:31 PM, Andrew Maclean
> <a.maclean at cas.edu.au> wrote:
>         Hey Bill, need some python practice?
>         
>         This could be useful in looking at the examples.
>         
>         I attach a python script taken from
>         http://furius.ca/pubcode/pub/conf/common/bin/depends-dot.html
>         And modified so that just the executable and the VTK nodes of
>         the graph
>         are traversed.
>         
>         Run it as:
>         python depends-dot ./Executable_File > depends.dot
>         Then:
>         neato -Tps -O depends.dot
>         Or:
>         dot -Tps -O depends.dot
>         
>         As you know you can also run:
>         cmake --graphviz=g.dot ..
>         Assuming the source is in ..
>         Then:
>         neato -Tps -O g.dot
>         Or:
>         dot -Tps -O g.dot
>         
>         However the python script (as modified) displays a lot more
>         information.
>         My modifications are:
>                    # Eliminate /usr or /lib libraries and keep the
>         first level
>         VTK links.
>                    #if fn.find('/usr') == -1 and fn.find('/lib') == -1
>         and
>         dfn.find('VTK') != -1:
>                    # Just the executable and the VTK nodes of the
>         graph are
>         traversed.
>                    if dfn.find('VTK') != -1:
>                       print '"%s" -> "%s";' % (fn, dfn)
>         
>         Just uncomment the first if statement to just get the
>         first-level
>         linkages to libraries.
>         
>         This might be a good start in visualising dependencies.
>         
>         I also found  perl script called cinclude2dot that  produces
>         an include
>         dependency graph see: http://www.flourish.org/cinclude2dot/ .
>         The
>         problem with this one is that it cannot follow links to
>         includes in
>         other directories. My perl is not good enough but it may be
>         possible to
>         parse CMakeCache.txt to pick up the include paths and traverse
>         those
>         directories too.
>         I ran this on the vtk directory and the output is ... well ...
>         spectacular and unreadable.
>         Try:
>         ./cinclude2dot --merge module > source.dot
>         
>         
>         The python script focuses on libraries and the perl one
>         focuses on
>         includes. So the approaches are different. However I feel the
>         perl one
>         could be more useful with the --merge module option since in
>         general vtk
>         include names reflect class names.
>         
>         Regards
>           Andrew
>         
>         
>         --
>         ___________________________________________
>         Andrew J. P. Maclean
>         Centre for Autonomous Systems
>         The Rose Street Building J04
>         The University of Sydney  2006  NSW
>         AUSTRALIA
>         Ph: +61 2 9351 3283
>         Fax: +61 2 9351 7474
>         URL: http://www.acfr.usyd.edu.au/
>         ___________________________________________
>         
>         _______________________________________________
>         Arb mailing list
>         Arb at vtk.org
>         http://public.kitware.com/cgi-bin/mailman/listinfo/arb
>         
> 
> 
> 
> -- 
> Jeff Baumes, Ph.D.
> Technical Lead, Kitware Inc.
> (518) 881-4932
> 

-- 
___________________________________________
Andrew J. P. Maclean
Centre for Autonomous Systems
The Rose Street Building J04
The University of Sydney  2006  NSW
AUSTRALIA
Ph: +61 2 9351 3283
Fax: +61 2 9351 7474
URL: http://www.acfr.usyd.edu.au/
___________________________________________

-------------- next part --------------
A non-text attachment was scrubbed...
Name: depends.py
Type: text/x-python
Size: 899 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/arb/attachments/20100823/fb7df96d/attachment-0006.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dependsview.py
Type: text/x-python
Size: 1605 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/arb/attachments/20100823/fb7df96d/attachment-0007.py>
-------------- next part --------------
I attempted some custom scripts to see the include structure of VTK.

python depends.py > vtkdepends.txt
vtkpython dependsview.py vtkdepends.txt

The first will create a two-column list of all includes from one class to another in VTK and must be called from the root of VTK source. The second visualizes the data with VTK itself and prints out the classes with the highest number of connections. Since the network makes a so-called "hairball", the second script optionally takes a maximum linkage cutoff to simplify the graph, e.g.

vtkpython dependsview.py vtkdepends.txt 10

will remove any classes with more than 10 links. Nodes are colored by number of connections. 

You can select a particular class and view all the includes for that class. Optionally you can control the depth of the tree and create an output suitable for graphviz. To do this, use get_subgraph.py and run it using vtkdepends.py as input.

python depends.py > vtkdepends.txt

Here we select a particular class (vtkParametricTorus), the topmost two levels of the tree and format for subsequent use by graphviz.
python get_subgraph.py -i vtkdepends.txt -c vtkParametricTorus -g -d 2 > x
dot -Tps -O x

Here we select a particular class (vtkParametricTorus), all levels of the tree and run it dependsview.py.
python get_subgraph.py -i vtkdepends.txt -c vtkParametricTorus > x
vtkpython dependsview.py x
-------------- next part --------------
A non-text attachment was scrubbed...
Name: get_subgraph.py
Type: text/x-python
Size: 4901 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/arb/attachments/20100823/fb7df96d/attachment-0008.py>


More information about the Arb mailing list