Tutorial

From TrustLet, a free, collaborative project for collecting and analyzing information about trust metrics.

Jump to: navigation, search

Code
( Tutorial - Examples )

The Trustlet is based on NetworkX. You can get started by checking out the NetworkX tutorial. Trustlet is developed to be a library in python that simplify the storage and the management of a graph. Trustlet provide several methods that are useful to analyze your network and plot some graphs about it.

[edit] First step

First of all we must allocate a network using this class, in the module trustlet.Dataset.Network:

Network
WeightedNetwork
WikiNetwork

or this class in the module trustlet.Dataset.Advogato:

KaitiakiNetwork
SqueakfoundationNetwork
Robots_netNetwork
AdvogatoNetwork

If you want to set up a generic network you had to use Network, or WeightedNetwork, else if you want to load a known-network (as Wikipedia Network) you had to use the appropriate class. See the documentation of the classes for more info about the methods or the parameters.

[edit] How to use your own network

First of all, we must build a network compatible with Trustlet, for instance create a networkx.XDiGraph object adding nodes and edges by a python script. Another simpler possibility is import data by dot or pajek format.

Now we instance an WeightedNetwork specifing some parameters:

to save your graph on disk

  • filepath
it's the location of .c2 file
  • cachedict
it's a dict thet identify the network, it contains parameters like
date or language
W = WeightedNetwork(filepath='/where/ever/you/want/network.c2',cachedict={'network':'yournetworkname','date':'2009-06-24','type':'whole','lang':'it'})

If the source of data is an instance of XDiGraph, we can set parameter from_graph

 N = XDiGraph()
 N.add_node(...)
 N.add_edge(...)
 N.add_...
 W = WeightedNetwork(filepath='/where/ever/you/want/network.c2',cachedict={'network':'yournetworkname','date':'2009-06-24','type':'whole','lang':'it'},from_graph=N)

Now you can save on disc yuor network calling W.save_c2(). If file is in ~/shared_datasets the dataset will be shared among trustlet's users.

Moreover, you can export the network in dot or pajek format, in order to manage it in other software suite.

Now you can call methods on the just created network...

W.info()
W. ...

some of those can save the result of computation in the same c2 in order to avoid waste of time recompution.

Now the network is stored into c2 file, you can load it instancing a WeightedNetwork using the same filepath and cachedict

Note: if you will create predgraphs, you have to use different folder for each network, in order to avoid overlapping in paths of predgraphs

[edit] NetfinityNetwork

An example of general network is Netfinity Network. The c2 file can be generated from free avaible dataset (http://the9ull.silix.org/netfinitynetwork/) and the script scripts/netfinitynetwork.py.

This script creates a c2 for input file. In order to see the cachedict used you can use scripts/lsc2.py


you can see here some examples.

This article is a stub. You can help by expanding it.
Personal tools