Chapter 3. Tulip Library

Table of Contents

1. Graphs
2. Hierarchy of graphs
3. Attributes
4. Properties
5. TUTORIAL Intro.
6. TUTORIAL 001 : Graphs creation, adding and deleting nodes or edges.
1. Header files
2. Creation of a Graph
3. Add nodes
4. Add edges
5. Delete an edge and a node
6. Printing the graph
7. Saving a graph
8. Graph deletion
9. Compiling and running the program.
10. Source Code
7. TUTORIAL 002 : Iterating over a graph (class Iterator and the macro forEach)
1. Header files (Same as Tutorial 1)
2. Iterating over all nodes
3. Iterating through a node predecessors
4. Iterating through a node successors
5. Iterating through a node neighbors (predecessors and successors)
6. Iterating through a node incoming edges
7. Iterating through a node outgoing edges
8. Iterating through a node adjacent edges
Don't forget memory leaks
9. Iterating on edges (all edges).
10. The forEach Macro
Source Code
8. TUTORIAL 003 : Properties
1. Header files and predefined properties
2. Creation of a property.
3. Initialize all properties.
4. Iterating over properties.
Source Code
9. TUTORIAL 004 : Create your first subgraph.
Source Code
10. TUTORIAL 005 : Properties and subgraphs
1. Introduction
2. Properties of subgraph1
3. Properties of subgraph2
Source Code
11. TUTORIAL 006 : Edges order.
1. Creation of the graph and its edges
2. Swap edges
3. Setting an order
Source Code
12. TUTORIAL 007 : Mutable Collection
13. TUTORIAL 008 : Graph Tests
14. TUTORIAL 009 : ObservableGraph
1. Our new class, GraphObserverTest :
2. The Main function

Efficient visualization of graphs and their usage for data analysis implies

This chapter describes the Tulip data structure that takes into account all the requirement of a graph visualization system. For each part we describe the general principle and then we give examples explaining how to do it with the Tulip library.

1. Graphs

The core of the Tulip library provides an interface for the manipulation of graphs. It enables one to access and modify the structure of a graph. The aim of this library is to be as general as possible and thus it manipulates a general class of graphs called directed pseudo-graphs. In a pseudo graph, there can be more than one edge between two nodes, and loops are permitted. A loop is an edge that links a node to itself. Furthermore, edges are directed, thus an edge u->v is distinct from an edge v->u.

Because we use pseudo-graphs, there can be more than one edge u->v, so it is not possible to distinguish two edges using only source and target (u,v). To make this possible, all the elements in Tulip are entities (C++ objects). Thus, even if two edges have the same source and the same target, they are distinct.

The elements of a graph are encapsulated in the graph. It is therefore not possible to access the graph's structure through elements, all operations must be done by querying the graph. For example, to know the source of an edge e of graph G, one must ask G, not e, what e's source is. This makes the use of the library less intuitive, but it minimizes memory usage for entities and allows to share them between subgraphs. Building a container of elements is cheap, because to handle elements, Tulip uses objects which use the same amount of storage as integers.

The library supports access and modification of the graph structure. The access to the structure are made by using iterators, one very important point is that the iterator are not persistent. Thus, if one modify the graph structure all the iterators on the graph structure can be invalid. This property enables to prevent from cloning the data structure and thus enables better access to it. For ease of use, Tulip includes mechanism that enables to transform an iterator into stable iterator, one must keep in mind that it corresponds to clone the data structure and thus, it should be use only if it is necessary.

If one uses Tulip only for the manipulation of one graph (no graph hierarchy), the list of available operations on the graph is given afterward. In the next section we will enhance the set of operations and the actions that they perform in order to manage a hierarchy of subgraphs

List of available modification operations

  • node addNode() : creates a new node in the graph and returns its identifier.

  • edge addEdge(node,node) : create a new edge in the graph, given the source and target.

  • void delNode(node) : deletes the given node.

  • void delEdge(edge) : deletes the given edge.

  • void reverse(edge) : reverses an edge (swaps source and target).

List of available access operations

  • unsigned int deg(node) : returns the degree of a node (number of edges).

  • unsigned int indeg(node) : returns the in degree of a node (number of times it is a target).

  • unsigned int outdeg(node) : returns the out degree of a node (number of times it is a source).

  • node source(edge) : returns the source of an edge.

  • node target(edge) : returns the target of an edge.

  • node opposite(edge,node) : it enables to obtain the opposite of a node of an edge.

  • Iterator * getInNodes(node) : returns an iterator on the predecessor nodes of a node.

  • Iterator * getOutNodes(node) : returns an iterator on the successor nodes of a node.

  • Iterator * getInOutNodes(node) : returns an iterator on the neighbor nodes of a node.

  • Iterator * getInEdges(node) : returns an iterator on the predecessor edges of a node.

  • Iterator * getOutEdges(node) : returns an iterator on the successor edges of a node.

  • Iterator * getInOutEdges(node) : returns an iterator on the neighbor edges of a node.