Changeset 7451:32d68dbbb9c9 in orange


Ignore:
Timestamp:
02/04/11 13:36:37 (3 years ago)
Author:
miha <miha.stajdohar@…>
Branch:
default
Convert:
38d07fd611eb9d0856ed2be51673422a2a782763
Message:

added examples to doc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orange/Orange/network/__init__.py

    r7425 r7451  
    187187constructed by:: 
    188188 
    189     >>> graph = orange.GraphAsMatrix(10, 0) 
     189    >>> graph = Orange.network.GraphAsMatrix(10, 0) 
    190190 
    191191A directed graph with 1000 vertices and edges of three types, stored with 
    192192adjacency trees would be constructed by:: 
    193193 
    194     >>> graph = orange.GraphAsTree(1000, 1, 3) 
     194    >>> graph = Orange.network.GraphAsTree(1000, 1, 3) 
    195195 
    196196Usage 
     
    242242    If objects contains a dictionary, its keys are vertex identifiers and the 
    243243    values in the dictionary should be integers, eg. 
    244      
    245     graph.objects = {} 
    246     graph.objects["Age"] = 0 
    247     graph.objects[None] = 1 
    248     graph.objects[orange] = 4 
    249  
     244        
     245    part of `network-graph.py`_ 
     246 
     247    .. literalinclude:: code/network-graph.py 
     248        :lines: 20-23 
     249  
    250250    If not a dictionary, objects can be any kind of sequence. Usually, you will 
    251251    give it a list of the same length as the number of vertices in the graph, 
     
    438438     
    439439        Return a diameter of the graph. 
     440         
     441Examples 
     442-------- 
     443 
     444How to use graphs, part of `network-graph.py`_ 
     445 
     446.. literalinclude:: code/network-graph.py 
     447    :lines: 9-56 
     448 
     449Results:: 
     450 
     451    [(1, 0), (2, 0), (2, 1)] 
     452    0.3 
     453    0.3 
     454    0.1 
     455    0.3 
     456    ['Gender', 'Height'] 
     457    [1, 2] 
     458    (None, None, None) 
     459    12.0 
     460    (None, 12, None) 
     461    1 
     462    0 
     463    1 
     464    0 
     465    0 
     466    1 
     467    (None, None, 3) 
     468    (None, None, None) 
     469 
     470How to use graphs with objects on edges, part of `network-graph-obj.py`_ 
     471 
     472.. literalinclude:: code/network-graph-obj.py 
     473    :lines: 9-59 
     474     
     475Results:: 
     476 
     477    [(1, 0), (2, 1)] 
     478    [1, 2, 3] 
     479    [1, 2, 3] 
     480    a string 
     481    None 
     482    a string 
     483    [1, 2, 3] 
     484    ['Gender'] 
     485    [1] 
     486    (None, None, None) 
     487    12.0 
     488    (None, 12, None) 
     489    1 
     490    0 
     491    1 
     492    0 
     493    0 
     494    1 
     495    (None, None, 3) 
     496    (None, None, None) 
     497 
     498An example of network analyses, part of `network-graph-analyses.py`_ (uses: 
     499`combination.net`_): 
     500 
     501.. literalinclude:: code/network-graph-analyses.py 
     502    :lines: 12-49 
     503     
     504Results:: 
     505 
     506    Connected components 
     507    [[0, 1, 2, 3, 4, 5, 6, 7, 8], [13, 14, 15, 16, 17, 18], [9, 10, 11, 12]] 
     508     
     509    Degree distribution 
     510    {1: 5, 2: 4, 3: 8, 4: 1, 5: 1} 
     511     
     512    Degrees 
     513    [4, 3, 3, 2, 2, 3, 2, 3, 2, 3, 3, 3, 3, 5, 1, 1, 1, 1, 1] 
     514     
     515    Hubs 
     516    [13, 0, 1] 
     517     
     518    Shortest path 
     519    [2, 0] 
     520     
     521    Distance 
     522    1 
     523     
     524    Diameter 
     525    4 
     526 
     527Subgraph image: 
     528 
     529.. image:: files/network-subgraph.png 
     530 
     531Additional functionality 
     532------------------------ 
     533 
     534Should you need any additional functionality, just tell us. Many things are 
     535trivial to implement in C++ and will be much faster than the corresponding 
     536scripts in Python. (In this regard, minimal span trees, maximal flows, coloring 
     537and shortest path search are, of course, not considered basic functionality. :) 
    440538 
    441539============================= 
     
    450548.. _network-read.py: code/network-read.py 
    451549.. _K5.net: code/K5.net 
     550.. _combination.net: code/combination.net 
    452551.. _network-widget.py: code/network-widget.py 
     552.. _network-graph-analyses.py: code/network-graph-analyses.py 
     553.. _network-graph.py: code/network-graph.py 
     554.. _network-graph-obj.py: code/network-graph-obj.py 
    453555 
    454556""" 
Note: See TracChangeset for help on using the changeset viewer.