@@ -107,7 +107,7 @@ class Hypergraph:
107107 If None, weight for all rows is assumed to be 1.
108108 keep_weights : bool, optional, default : True
109109 Whether or not to use existing weights when input is StaticEntity, or StaticEntitySet.
110- aggregateby : str, optional, {'count', 'sum', 'mean', 'median', max', 'min', 'first','last', None}, default : 'count '
110+ aggregateby : str, optional, {'count', 'sum', 'mean', 'median', max', 'min', 'first','last', None}, default : 'sum '
111111 Method to aggregate cell_weights of duplicate rows if setsystem is of type pandas.DataFrame or
112112 StaticEntity. If None all cell weights will be set to 1.
113113 use_nwhy : boolean, optional, default : False
@@ -126,7 +126,7 @@ def __init__(
126126 name = None ,
127127 static = False ,
128128 weights = None ,
129- aggregateby = "count " ,
129+ aggregateby = "sum " ,
130130 use_nwhy = False ,
131131 filepath = None ,
132132 ):
@@ -1146,40 +1146,40 @@ def incidence_matrix(self, weights=False, index=False):
11461146 return self .edges .incidence_matrix (index = index )
11471147
11481148 @staticmethod
1149- def incidence_to_adjacency (M , s = 1 , weights = True ):
1149+ def _incidence_to_adjacency (M , s = 1 , weights = False ):
11501150 """
1151- Helper method to obtain adjacency matrix from incidence matrix.
1151+ Helper method to obtain adjacency matrix from
1152+ boolean incidence matrix for s-metrics.
1153+ Self loops are note supported.
1154+ The adjacency matrix will define an s-linegraph.
11521155
11531156 Parameters
11541157 ----------
1155- M : scipy.sparse.csr.csr_matrix
1158+ M : scipy.sparse.csr.csr_matrix
1159+ incidence matrix of 0's and 1's
11561160
11571161 s : int, optional, default: 1
11581162
1159- weights : bool, dict optional, default=True
1160- If False all nonzero entries are 1.
1161- Otherwise, weights will be as in product.
1163+ # weights : bool, dict optional, default=True
1164+ # If False all nonzero entries are 1.
1165+ # Otherwise, weights will be as in product.
11621166
11631167 Returns
11641168 -------
11651169 a matrix : scipy.sparse.csr.csr_matrix
11661170
11671171 """
1168- A = M .dot (M .transpose ())
1169- if issparse (A ):
1170- A .setdiag (0 )
1171- B = (A >= s ) * 1
1172- A = A .multiply (B )
1173- else :
1174- np .fill_diagonal (A , 0 )
1175- B = (A >= s ) * 1
1176- A = np .multiply (A , B )
1172+ M = csr_matrix (M )
1173+ weights = False ## currently weighting is not supported
11771174
11781175 if weights == False :
1179- A = (A > 0 ) * 1
1180- return csr_matrix (A )
1176+ A = M .dot (M .transpose ())
1177+ A .setdiag (0 )
1178+ A = (A >= s ) * 1
1179+ return A
1180+
11811181
1182- def adjacency_matrix (self , index = False , s = 1 , weights = True ):
1182+ def adjacency_matrix (self , index = False , s = 1 ): ## , weights=False ):
11831183 """
11841184 The sparse weighted :term:`s-adjacency matrix`
11851185
@@ -1201,13 +1201,14 @@ def adjacency_matrix(self, index=False, s=1, weights=True):
12011201 row dictionary : dict
12021202
12031203 """
1204+ weights = False ## Currently default weights are not supported.
12041205 M = self .incidence_matrix (index = index , weights = weights )
12051206 if index :
1206- return Hypergraph .incidence_to_adjacency (M [0 ], s = s , weights = weights ), M [1 ]
1207+ return Hypergraph ._incidence_to_adjacency (M [0 ], s = s , weights = weights ), M [1 ]
12071208 else :
1208- return Hypergraph .incidence_to_adjacency (M , s = s , weights = weights )
1209+ return Hypergraph ._incidence_to_adjacency (M , s = s , weights = weights )
12091210
1210- def edge_adjacency_matrix (self , index = False , s = 1 , weights = True ):
1211+ def edge_adjacency_matrix (self , index = False , s = 1 , weights = False ):
12111212 """
12121213 The weighted :term:`s-adjacency matrix` for the dual hypergraph.
12131214
@@ -1235,16 +1236,18 @@ def edge_adjacency_matrix(self, index=False, s=1, weights=True):
12351236 If index=True, returns a dictionary column_index:edge_uid
12361237
12371238 """
1239+ weights = False ## Currently default weights are not supported
1240+
12381241 M = self .incidence_matrix (index = index , weights = weights )
12391242 if index :
12401243 return (
1241- Hypergraph .incidence_to_adjacency (
1244+ Hypergraph ._incidence_to_adjacency (
12421245 M [0 ].transpose (), s = s , weights = weights
12431246 ),
12441247 M [2 ],
12451248 )
12461249 else :
1247- return Hypergraph .incidence_to_adjacency (
1250+ return Hypergraph ._incidence_to_adjacency (
12481251 M .transpose (), s = s , weights = weights
12491252 )
12501253
0 commit comments