Gconvert is a C++ program written by Pascal Pons to convert different graph formats. It is published under the GNU General Public License.

Download Gconvert : Source code Win32 executable

To compile the program type the command "make". If you do not have the "make" utility try : "g++ -O3 Gconvert.cpp graph.cpp -o Gconvert".

The supported formats are all text format. Each line is interpreted as a list of strings separated by delimiters (default is space and tabulation). The strings are vertices names, times or weights (according to the formats). The two first parameters specify the formats of the input and output data. These two parameters are required and must be one of the following formats:

Parameter | Graph type | Line format | Line meaning |

AEL (Adjacency Edge List)
| undirected, unweighted | source dest_1 dest_2 ... dest_n | There is an undirected edge between the vertex "source" and each vertex "dest_k". |

AAL (Adjacency Arc List)
| directed, unweighted | source dest_1 dest_2 ... dest_n | There is a directed arc between the vertex "source" and each vertex "dest_k". |

EL (Edge List)
| undirected, unweighted | source dest | There is one undirected edge between the vertex "source" and "dest". If the line has more than 2 items, the lasts items are ignored. |

DEL (Dynamic Edge List)
| undirected, dynamic, unweighted | source dest time | There is one undirected edge between the vertex "source" and "dest" at a given "time". If the line has more than 3 items, the lasts items are ignored. |

AL (Arc List)
| directed, unweighted | source dest | There is one directed arc between the vertex "source" and "dest". If the line has more than 2 items, the lasts items are ignored. |

DAL (Dynamic Arc List)
| directed, dynamic, unweighted | source dest time | There is one directed arc between the vertex "source" and "dest" at a given "time". If the line has more than 2 items, the lasts items are ignored. |

WEL (Weighted Edge List)
| undirected, weighted | source dest [weight] | There is one undirected edge between the vertex "source" and "dest" with a given weight. If the weight is omitted, default weight 1.0 is used. |

DWEL (Dynamic Weighted Edge List)
| undirected, dynamic, weighted | source dest time [weight] | There is one undirected edge between the vertex "source" and "dest" at a given "time" with a given weight. If the weight is omitted, default weight 1.0 is used. |

WAL (Weighted Arc List)
| directed, weighted | source dest [weight] | There is one directed arc between the vertex "source" and "dest" with a given weight. If the weight is omitted, default weight 1.0 is used. |

DWAL (Dynamic Weighted Arc List)
| directed, dynamic, weighted | source dest time [weight] | There is one directed arc between the vertex "source" and "dest" at a given "time" with a given weight. If the weight is omitted, default weight 1.0 is used. |

CL (Clique List) input only
| undirected, unweighted | vertex_1 vertex_2 ... vertex_n | Each pair of the n vertices are linked by an undirected edge. |

WCL (WeightedClique List) input only
| undirected, weighted | vertex_1 vertex_2 ... vertex_n | Each pair of the n vertices are linked by an undirected edge of weight 2/(n-1). hence each clique has a total weight n. |

In all the cases:

- Zero degree vertices are not allowed
- Time is always required for dynamic formats
- Weight may be omitted, in this case default weight 1.0 is used

If one of these parameters is omitted, the standard input or the standard output is used (useful if you need to pipe the program with another one).

**-mxxx (Multi edges policy):****-madd (default for static graphs):**Multi edges are converted into a single edge which weight is the sum of the weights of the multi edges.**-mmulti:**Multi edges are allowed. This is the only supported policy for dynamic output.**-maddexp (only dynamic to static conversions):**The weights are added but the weight of each edge linearly decreases with a characteristic life time given by the -l option**-maddlin (only dynamic to static conversions):**The weights are added but the weight of each edge exponentially decreases with a characteristic life time given by the -l option

**-lxxx (only for dynamic input):**

Specify the characteristic life time of the dynamic edges. The interpretation of this value is different according to the multi edges policy chosen. If the policies -madd or -mmulti are chosen, the edges exist with their initial weight from their creation and disappear after the chosen characteristic time. If the policies -maddlin is chosen, the edges also disappear after the chosen characteristic time but their weight linearly decreases during their life time. If the policies -maddexp is chosen, the edges never disappear but their weight exponentially decreases such that their it is divided by two after each characteristic time. This parameter must be specified for -maddlin and -maddexp policies. And if this parameter is omitted, we consider that the edges never disappear.**-txxx (only for dynamic input):**

Specify the output time of a dynamic graph. An edge created after this time will be ignored. This time is also important to compute the weight of the edges in linear and exponential decrease policies. If omitted, it is equal to the highest date of the eges.**-dxxx (Delimiters):**

Specify the characters that are delimiters in xxx (default is " \t"). "\t" is interpreted as a tabulation character.**-n (Number):**

Rename the vertices with numbers from 0 to nb_vertices-1. An index can be obtained with the following option.**-i [index_file] (Index):**

Make an index of the numbers given by -n option in the file index_file. If this file is omitted, the index is printed just before the ouput graph. The index prints one line "new_name old_name" for each vertex.-
**-c (Largest connected component):**

Only keep the largest (in number of vertices) connected component of the graph. If several components have the same size, one of them is arbitrary chosen. **-q (Quiet):**

Do not display any warning message.**-h (Help):**

print the help.

- directed to undirected: Each arc of the input graph is considered as an undirected edge.
- undirected to directed: Each edge of the input graph is considered as two directed arcs (of same weight).
- unweighted to weighted: Each edge (arc) of the input graph has a weight equal to 1.0
- static to dynamic is impossible

**Gconvert AEL EL G1.txt -o G2.txt**

Convert the input file "G1.txt" from Adjacency Edge List format to Edge List format. The output is written in file "G2.txt".**Gconvert AL AAL G1.txt -o G2.txt -d;**

Convert the input file "G1.txt" from Arc List format to Adjacency Arc List format. The output is written in file "G2.txt". The delimiter between vertices is ";" (useful for data exported from an excel form).**Gconvert EL AL G1.txt -o G2.txt -mmulti -C**

Convert the input file "G1.txt" from Edge List format to Arc List format. The output is written in file "G2.txt". Multi edges are allowed and only the largest connected component of the graph is kept.**Gconvert WCL WEL G1.txt -n -i index.txt**

Convert the input file "G1.txt" from Weighted Clique List format to Weighted Edge List format. The output is written to standard output of the program. The vertices are renamed with number from 0 to nb_vertices and an index is created in the file "index.txt".**Graph_generator | Gconvert AEL EL | Another_program**

This command line allows to use a program ("Graph_generator") that generates graph in Adjacency Edge List format on its standard output with "Another_program" that need an input graph in Edge List format on its standard input.

If you find a bug, please send a bug report to pons@liafa.jussieu.fr including the input file and the parameters that caused the bug.

You can also send me any comment or suggestion about the program.

Back to home page