Changeset 3708:a950a76b6d9c in orange
 Timestamp:
 05/28/07 11:54:17 (7 years ago)
 Branch:
 default
 Convert:
 9b32835d54521214dab345df69aa6dd4cb6341e6
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

source/orangeom/networkoptimization.cpp
r3703 r3708 472 472 Py_INCREF(graph>coors); 473 473 return (PyObject *)graph>coors; 474 } 475 476 PyObject *NetworkOptimization_getHubs(PyObject *self, PyObject *args) PYARGS(METH_VARARGS, "(n) > HubList") 477 { 478 int n; 479 480 if (!PyArg_ParseTuple(args, "n:NetworkOptimization.getHubs", &n)) 481 return NULL; 482 483 CAST_TO(TNetworkOptimization, graph); 484 485 int *vertexPower = new int[graph>nVertices]; 486 487 int i; 488 for (i=0; i < graph>nVertices; i++) 489 { 490 vertexPower[i] = 0; 491 } 492 493 for (i=0; i < graph>nLinks; i++) 494 { 495 vertexPower[graph>links[i][0]]++; 496 vertexPower[graph>links[i][1]]++; 497 } 498 499 PyObject* hubList = PyList_New(n); 500 501 for (i=0; i < n; i++) 502 { 503 int j; 504 int ndx_max = 1; 505 int max = 0; 506 for (j=0; j < graph>nVertices; j++) 507 { 508 if (vertexPower[j] > max) 509 { 510 ndx_max = j; 511 max = vertexPower[j]; 512 } 513 } 514 //cout << "pow: " << vertexPower[ndx_max] << " ndx: " << ndx_max << endl; 515 516 vertexPower[ndx_max] = 2; 517 PyList_SetItem(hubList, i, PyInt_FromLong(ndx_max)); 518 } 519 520 delete [] vertexPower; 521 return hubList; 474 522 } 475 523
Note: See TracChangeset
for help on using the changeset viewer.