Skip to content

Commit 4ee3452

Browse files
committed
Replace cost_size with new function make_cost_array.
1 parent fa1958b commit 4ee3452

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

brainx/util.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,32 +60,36 @@ def format_matrix2(data,s,sc,c,lk,co,idc = [],costlist=[],nouptri = False):
6060
return cmat
6161

6262

63-
def cost_size(nnodes):
64-
"""Make N+1-length cost array, with N the number of possible edges.
63+
def make_cost_array(n_nodes, cost=0.5):
64+
"""Make cost array of length cost * (the number of possible edges).
6565
6666
Parameters
6767
----------
68-
nnodes: integer
68+
n_nodes: integer
6969
Number of nodes in the graph.
7070
71+
cost: float, optional
72+
Value between 0 and 1 (0.5 by default). The length of
73+
cost_array will be set to cost * tot_edges.
74+
7175
Returns
7276
-------
73-
costs: numpy array
77+
cost_array: numpy array
7478
N+1-length array of costs, with N the number of possible
7579
undirected edges in the graph. The costs range from 0 to 1 and
7680
are equally-spaced.
7781
7882
tot_edges: float
7983
Number of possible undirected edges in the graph.
8084
81-
half_tot_edges: float
82-
tot_edges / 2
85+
Notes
86+
-----
87+
This is an edited version of the former function cost_size.
8388
8489
"""
85-
tot_edges = 0.5 * nnodes * (nnodes - 1)
86-
costs = np.array(range(int(tot_edges) + 1), dtype=float) / tot_edges
87-
half_tot_edges = tot_edges / 2
88-
return costs, tot_edges, half_tot_edges
90+
tot_edges = 0.5 * n_nodes * (n_nodes - 1)
91+
costs = np.array(range(int(tot_edges * cost)), dtype=float) / tot_edges
92+
return costs, tot_edges
8993

9094

9195
def store_metrics(b, s, co, metd, arr):

0 commit comments

Comments
 (0)