Changeset 7282:ce6377d6231d in orange


Ignore:
Timestamp:
02/03/11 00:09:50 (3 years ago)
Author:
miha <miha.stajdohar@…>
Branch:
default
Convert:
6796b82b1cc0e4fb5620a9a71e841a86a2ae7ef3
Message:
 
File:
1 edited

Legend:

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

    r7256 r7282  
     1"""  
     2.. index:: network 
     3 
     4Network analysis and layout optimization. 
     5 
     6======= 
     7Network 
     8======= 
     9 
     10.. autoclass:: Orange.network.Network 
     11   :members: 
     12    
     13=========================== 
     14Network Layout Optimization 
     15=========================== 
     16 
     17.. autoclass:: Orange.network.NetworkOptimization 
     18   :members: 
     19    
     20============================= 
     21Community Detection in Graphs 
     22============================= 
     23 
     24.. autoclass:: Orange.network.NetworkClustering 
     25   :members: 
     26    
     27""" 
     28import random 
     29import os 
     30 
     31import orange 
    132import orangeom 
    2 import random 
    333 
    434from orange import Graph, GraphAsList, GraphAsMatrix, GraphAsTree 
     
    1343 
    1444class Network(orangeom.Network): 
    15     """Orange data structure for representing directed and undirected networks with various types of weighted connections and other data.""" 
     45     
     46    """Data structure for representing directed and undirected networks. 
     47     
     48    Network class holds network structure information and supports basic  
     49    network analysis. Network class is inherited from orange.GraphAsList.  
     50    Refer to orange.GraphAsList for more graph analysis tools. See the  
     51    orangeom.Pathfinder class for a way to simplify your network. 
     52     
     53    .. attribute:: coors 
     54    
     55        Coordinates for all vertices. They are initialized to random positions.  
     56        You can modify them manually or use one of the optimization algorithms.  
     57        Usage: coors[0][i], coors[1][i]; 0 for x-axis, 1 for y-axis 
     58        
     59    .. attribute:: items 
     60    
     61        ExampleTable with information about vertices. Number of rows should  
     62        match the number of vertices. 
     63        
     64    .. attribute:: links 
     65    
     66        ExampleTable with information about edges. Number of rows should match  
     67        the number of edges. Two float attributes named "u" and "v" must be in  
     68        links table domain to relate the data of an example to an edge. Here,  
     69        egde is defined by two vertices "u" and "v". 
     70 
     71    .. attribute:: optimization 
     72    
     73        An instance of the NetworkOptimization class. Various network layout  
     74        optimization methods can be applied to the network through this  
     75        attribute.  
     76         
     77    .. method:: fromDistanceMatrix(matrix, lower, upper, kNN=0): 
     78         
     79        Creates edges between vertices with the distance within given  
     80        threshold. The . 
     81         
     82        :param matrix: number of objects in a matrix must match the number  
     83            of vertices in a network. 
     84        :type matrix: Orange.core.SymMatrix 
     85        :param lower: lower distance bound. 
     86        :type lower: float 
     87        :param upper: upper distance bound. 
     88        :type upper: float 
     89        :param kNN: specifies the minimum number of closest vertices to be  
     90            connected. 
     91        :type kNN: int 
     92     
     93    """ 
    1694     
    1795    def __init__(self, *args): 
     96        """:param nVertices: number of vertices (default 1) 
     97        :param nEdges: number of edge types (default 1) 
     98        :param directedGraph: directed edges (default True) 
     99         
     100        """ 
    18101        #print "orngNetwork.Network" 
    19102        self.optimization = NetworkOptimization(self) 
     
    21104         
    22105    def getDistanceMatrixThreshold(self, matrix, ratio): 
    23         """Return lower and upper distance threshold values for given ratio of edges""" 
     106        """Return lower and upper distance threshold values for the given  
     107        ratio of edges 
     108         
     109        """ 
    24110        values = [] 
    25111        for i in range(matrix.dim): 
     
    31117         
    32118    def save(self, fileName): 
    33         """Saves network to Pajek (.net) file.""" 
     119        """Save the network to a Pajek (.net) or GML file format.  
     120        data.Table items and links are saved automatically if the value is not  
     121        None. They are saved to "file_items.tab" and "file_links.tab" files. 
     122         
     123        :param fileName: file path 
     124        :type fileName: string 
     125         
     126        """ 
    34127        self.saveNetwork(fileName) 
    35128         
    36     def saveNetwork(self, fileName): 
    37         """Save network to file.""" 
    38          
     129    def saveNetwork(self, fileName):         
    39130        try: 
    40131            root, ext = os.path.splitext(fileName) 
     
    52143 
    53144    def saveGML(self, fp): 
    54         """Save network to GML (.gml) file format.""" 
    55          
     145        """Save network to GML (.gml) file format. 
     146         
     147        :param fp: file pointer 
     148        :type fp: file 
     149         
     150        """ 
    56151        fp.write("graph\n[\n") 
    57152        tabs = "\t" 
     
    80175         
    81176    def savePajek(self, fp): 
    82         """Save network to Pajek (.net) file format.""" 
     177        """Save network to Pajek (.net) file format. 
     178         
     179        :param fp: file pointer 
     180        :type fp: file 
     181         
     182        """ 
    83183        name = '' 
    84184        fp.write('### This file was generated with Orange Network Visualizer ### \n\n\n') 
     
    151251    @staticmethod 
    152252    def read(fileName, directed=0): 
    153         """Read network. Supported network formats: from Pajek (.net) file, GML.""" 
     253        """Read network. Supported network formats: from Pajek (.net) file,  
     254        GML. 
     255         
     256        :param fileName: file path 
     257        :type fileName: string 
     258        :param directed: (default False) 
     259        :type directed: bool 
     260         
     261        """ 
    154262        if type(fileName) == file: 
    155263            root, ext = os.path.splitext(fileName.name) 
Note: See TracChangeset for help on using the changeset viewer.