python-igraph manual

For using igraph from Python

   Home       Trees       Indices       Help   
Package igraph :: Module datatypes :: Class TriadCensus
[hide private]

Class TriadCensus

source code

object --+    
         |    
     tuple --+
             |
            TriadCensus

Triad census of a graph.

This is a pretty simple class - basically it is a tuple, but it allows the user to refer to its individual items by the following triad names:

  • 003 -- the empty graph
  • 012 -- a graph with a single directed edge (A --> B, C)
  • 102 -- a graph with a single mutual edge (A <-> B, C)
  • 021D -- the binary out-tree (A <-- B --> C)
  • 021U -- the binary in-tree (A --> B <-- C)
  • 021C -- the directed line (A --> B --> C)
  • 111D -- A <-> B <-- C
  • 111U -- A <-> B --> C
  • 030T -- A --> B <-- C, A --> C
  • 030C -- A <-- B <-- C, A --> C
  • 201 -- A <-> B <-> C
  • 120D -- A <-- B --> C, A <-> C
  • 120U -- A --> B <-- C, A <-> C
  • 120C -- A --> B --> C, A <-> C
  • 210C -- A --> B <-> C, A <-> C
  • 300 -- the complete graph (A <-> B <-> C, A <-> C)

Attribute and item accessors are provided. Due to the syntax of Python, attribute names are not allowed to start with a number, therefore the triad names must be prepended with a lowercase t when accessing them as attributes. This is not necessary with the item accessor syntax.

Examples:

>>> from igraph import Graph
>>> g=Graph.Erdos_Renyi(100, 0.2, directed=True)
>>> tc=g.triad_census()
>>> print tc.t003                     #doctest:+SKIP
39864
>>> print tc["030C"]                  #doctest:+SKIP
1206
Instance Methods [hide private]
 
__getitem__(self, idx)
x[y]
source code
 
__getattr__(self, attr) source code
 
__repr__(self)
repr(x)
source code
 
__str__(self)
str(x)
source code

Inherited from tuple: __add__, __contains__, __eq__, __ge__, __getattribute__, __getnewargs__, __getslice__, __gt__, __hash__, __iter__, __le__, __len__, __lt__, __mul__, __ne__, __new__, __rmul__, count, index

Inherited from object: __delattr__, __format__, __init__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Variables [hide private]
  _remap = {'003': 0, '012': 1, '021C': 5, '021D': 3, '021U': 4,...
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__getitem__(self, idx)
(Indexing operator)

source code 

x[y]

Overrides: tuple.__getitem__
(inherited documentation)

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

Class Variable Details [hide private]

_remap

Value:
{'003': 0,
 '012': 1,
 '021C': 5,
 '021D': 3,
 '021U': 4,
 '030C': 9,
 '030T': 8,
 '102': 2,
...

   Home       Trees       Indices       Help