Changeset 3999:28cc097066ef in orange


Ignore:
Timestamp:
07/19/07 13:18:49 (7 years ago)
Author:
janezd <janez.demsar@…>
Branch:
default
Convert:
dc5c4cb11fe57a1c28bad6255f4f9fabc1f76415
Message:
  • added a few functions returning the vertex powers (which were meant to be used in graph drawing, but they're not)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • source/orangeom/networkoptimization.cpp

    r3751 r3999  
    483483} 
    484484 
     485int *getVertexPowers(TNetworkOptimization *graph) 
     486{ 
     487    int *vertexPower = new int[graph->nVertices]; 
     488 
     489    int i; 
     490    for (i=0; i < graph->nVertices; i++) 
     491    { 
     492        vertexPower[i] = 0; 
     493    } 
     494 
     495    for (i=0; i < graph->nLinks; i++) 
     496    { 
     497        vertexPower[graph->links[0][i]]++; 
     498        vertexPower[graph->links[1][i]]++; 
     499    } 
     500     
     501  return vertexPower; 
     502} 
     503 
     504PyObject *NetworkOptimization_getVertexPowers(PyObject *self, PyObject *) PYARGS(METH_NOARGS, "() -> list") 
     505{ 
     506  PyTRY 
     507    CAST_TO(TNetworkOptimization, graph); 
     508    int *vertexPower = getVertexPowers(graph); 
     509    PyObject *pypowers = PyList_New(graph->nVertices); 
     510    for(int i =0; i < graph->nVertices; i++) 
     511      PyList_SetItem(pypowers, i, PyInt_FromLong(vertexPower[i])); 
     512    delete [] vertexPower; 
     513    return pypowers; 
     514  PyCATCH; 
     515} 
     516 
    485517PyObject *NetworkOptimization_getHubs(PyObject *self, PyObject *args) PYARGS(METH_VARARGS, "(n) -> HubList") 
    486518{ 
     
    493525    CAST_TO(TNetworkOptimization, graph); 
    494526 
    495     int *vertexPower = new int[graph->nVertices]; 
    496  
    497     int i; 
    498     for (i=0; i < graph->nVertices; i++) 
    499     { 
    500         vertexPower[i] = 0; 
    501     } 
    502  
    503     for (i=0; i < graph->nLinks; i++) 
    504     { 
    505         vertexPower[graph->links[0][i]]++; 
    506         vertexPower[graph->links[1][i]]++; 
    507     } 
    508  
     527  int i; 
     528  int *vertexPower = getVertexPowers(graph); 
     529   
    509530    PyObject* hubList = PyList_New(n); 
    510531     
Note: See TracChangeset for help on using the changeset viewer.