Preparation
The First Steps of Programming
First, create a python file and import net-bench. Also import networkx, because
we sometimes need functions of that package.
The package NetworkX is always written as networkx for the import in python and
usually gets the alias nx to shorten it.
Importing a graph.
First you need to import a graph. This can be done by using a so-called Interface of the chair or with a file. For the latter option there are several formats of data, like the Pajek-format or the gexf-format, which is used by Gephi. For those forms of textfiles, NetworkX offers its own methods to convert the data into a graph of the right format:
read_pajekfor Pajek-filesread_gexffor Graph Exchange XML Format- You can find an overview over all compatible formats here
If you want to use the interface, continue reading here.
Note
We suggest to import the data as networkx.DiGrahph in the beginning.
Clean-Up (optional)
Sometimes edges that go from the same nodes to the same nodes need to be deleted from
the network. This can be done with networkx:
In this case, selfloops are deleted. They sometimes exist in crawled networks.