scikit-network 0.32.1__cp39-cp39-win_amd64.whl → 0.33.0__cp39-cp39-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of scikit-network might be problematic. Click here for more details.

Files changed (60) hide show
  1. {scikit_network-0.32.1.dist-info → scikit_network-0.33.0.dist-info}/AUTHORS.rst +0 -1
  2. {scikit_network-0.32.1.dist-info → scikit_network-0.33.0.dist-info}/METADATA +9 -3
  3. {scikit_network-0.32.1.dist-info → scikit_network-0.33.0.dist-info}/RECORD +60 -60
  4. {scikit_network-0.32.1.dist-info → scikit_network-0.33.0.dist-info}/WHEEL +1 -1
  5. sknetwork/__init__.py +1 -1
  6. sknetwork/classification/diffusion.py +4 -3
  7. sknetwork/classification/knn.py +4 -3
  8. sknetwork/classification/metrics.py +3 -3
  9. sknetwork/classification/propagation.py +6 -5
  10. sknetwork/classification/vote.cp39-win_amd64.pyd +0 -0
  11. sknetwork/classification/vote.cpp +1 -1
  12. sknetwork/clustering/leiden.py +2 -1
  13. sknetwork/clustering/leiden_core.cp39-win_amd64.pyd +0 -0
  14. sknetwork/clustering/leiden_core.cpp +1 -1
  15. sknetwork/clustering/louvain.py +3 -3
  16. sknetwork/clustering/louvain_core.cp39-win_amd64.pyd +0 -0
  17. sknetwork/clustering/louvain_core.cpp +1 -1
  18. sknetwork/clustering/tests/test_kcenters.py +5 -37
  19. sknetwork/data/__init__.py +1 -1
  20. sknetwork/data/base.py +7 -2
  21. sknetwork/data/load.py +18 -21
  22. sknetwork/data/models.py +15 -15
  23. sknetwork/data/parse.py +19 -17
  24. sknetwork/data/tests/test_API.py +3 -3
  25. sknetwork/data/tests/test_base.py +2 -2
  26. sknetwork/data/tests/test_toy_graphs.py +33 -33
  27. sknetwork/data/toy_graphs.py +35 -43
  28. sknetwork/embedding/base.py +3 -0
  29. sknetwork/embedding/louvain_embedding.py +0 -26
  30. sknetwork/embedding/svd.py +0 -4
  31. sknetwork/embedding/tests/test_louvain_embedding.py +9 -4
  32. sknetwork/embedding/tests/test_svd.py +6 -0
  33. sknetwork/gnn/gnn_classifier.py +1 -1
  34. sknetwork/hierarchy/louvain_hierarchy.py +10 -6
  35. sknetwork/hierarchy/paris.cp39-win_amd64.pyd +0 -0
  36. sknetwork/hierarchy/paris.cpp +757 -755
  37. sknetwork/hierarchy/paris.pyx +4 -3
  38. sknetwork/hierarchy/tests/test_metrics.py +4 -4
  39. sknetwork/linalg/diteration.cp39-win_amd64.pyd +0 -0
  40. sknetwork/linalg/diteration.cpp +1 -1
  41. sknetwork/linalg/push.cp39-win_amd64.pyd +0 -0
  42. sknetwork/linalg/push.cpp +123 -123
  43. sknetwork/ranking/betweenness.cp39-win_amd64.pyd +0 -0
  44. sknetwork/ranking/betweenness.cpp +1 -1
  45. sknetwork/regression/diffusion.py +6 -4
  46. sknetwork/topology/cliques.cp39-win_amd64.pyd +0 -0
  47. sknetwork/topology/cliques.cpp +123 -123
  48. sknetwork/topology/core.cp39-win_amd64.pyd +0 -0
  49. sknetwork/topology/core.cpp +123 -123
  50. sknetwork/topology/minheap.cp39-win_amd64.pyd +0 -0
  51. sknetwork/topology/minheap.cpp +1 -1
  52. sknetwork/topology/triangles.cp39-win_amd64.pyd +0 -0
  53. sknetwork/topology/triangles.cpp +1 -1
  54. sknetwork/topology/weisfeiler_lehman_core.cp39-win_amd64.pyd +0 -0
  55. sknetwork/topology/weisfeiler_lehman_core.cpp +1 -1
  56. sknetwork/utils/__init__.py +1 -1
  57. sknetwork/utils/values.py +5 -3
  58. sknetwork/visualization/graphs.py +1 -1
  59. {scikit_network-0.32.1.dist-info → scikit_network-0.33.0.dist-info}/LICENSE +0 -0
  60. {scikit_network-0.32.1.dist-info → scikit_network-0.33.0.dist-info}/top_level.txt +0 -0
@@ -11,10 +11,10 @@ from typing import Union
11
11
  import numpy as np
12
12
  from scipy import sparse
13
13
 
14
- from sknetwork.data.base import Bunch
14
+ from sknetwork.data.base import Dataset
15
15
 
16
16
 
17
- def house(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
17
+ def house(metadata: bool = False) -> Union[sparse.csr_matrix, Dataset]:
18
18
  """House graph.
19
19
 
20
20
  * Undirected graph
@@ -46,7 +46,7 @@ def house(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
46
46
  if metadata:
47
47
  x = np.array([0, -1, -1, 1, 1])
48
48
  y = np.array([2, 1, -1, -1, 1])
49
- graph = Bunch()
49
+ graph = Dataset()
50
50
  graph.adjacency = adjacency
51
51
  graph.position = np.vstack((x, y)).T
52
52
  graph.name = 'house'
@@ -55,7 +55,7 @@ def house(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
55
55
  return adjacency
56
56
 
57
57
 
58
- def bow_tie(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
58
+ def bow_tie(metadata: bool = False) -> Union[sparse.csr_matrix, Dataset]:
59
59
  """Bow tie graph.
60
60
 
61
61
  * Undirected graph
@@ -86,7 +86,7 @@ def bow_tie(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
86
86
  if metadata:
87
87
  x = np.array([0, -1, 1, -1, 1])
88
88
  y = np.array([0, 1, 1, -1, -1])
89
- graph = Bunch()
89
+ graph = Dataset()
90
90
  graph.adjacency = adjacency
91
91
  graph.position = np.vstack((x, y)).T
92
92
  graph.name = 'bow_tie'
@@ -95,7 +95,7 @@ def bow_tie(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
95
95
  return adjacency
96
96
 
97
97
 
98
- def karate_club(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
98
+ def karate_club(metadata: bool = False) -> Union[sparse.csr_matrix, Dataset]:
99
99
  """Karate club graph.
100
100
 
101
101
  * Undirected graph
@@ -150,7 +150,7 @@ def karate_club(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
150
150
  [-0.33, -0.15, -0.01, -0.28, -0.64, -0.75, -0.76, -0.25, 0.09, 0.23, -0.62, -0.4, -0.53, -0.07,
151
151
  0.55, 0.64, -1., -0.42, 0.6, -0.01, 0.45, -0.34, 0.61, 0.41, 0.14, 0.28, 0.68, 0.21,
152
152
  0.12, 0.54, 0.19, 0.09, 0.38, 0.33])
153
- graph = Bunch()
153
+ graph = Dataset()
154
154
  graph.adjacency = adjacency
155
155
  graph.labels = labels
156
156
  graph.position = np.vstack((x, y)).T
@@ -160,7 +160,7 @@ def karate_club(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
160
160
  return adjacency
161
161
 
162
162
 
163
- def miserables(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
163
+ def miserables(metadata: bool = False) -> Union[sparse.csr_matrix, Dataset]:
164
164
  """Co-occurrence graph of the characters in the novel Les miserables by Victor Hugo.
165
165
 
166
166
  * Undirected graph
@@ -257,7 +257,7 @@ def miserables(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
257
257
  0.05, 0.12, 0.82, 0.44, 0.06, -0.2, -0.4, -0.28, -0.68, -0.79, -0.4, -0.07, -0.51, -0.17, -0.03,
258
258
  -0.09, -0.14, -0.04, -0.04, -0.07, -0.06, -0.11, -0.06, -0.35, 0.24, 0.19, 0.22, 0.29, -0.2,
259
259
  0.06, 0.14, 0.3, -0.1])
260
- graph = Bunch()
260
+ graph = Dataset()
261
261
  graph.adjacency = adjacency
262
262
  graph.names = np.array(names)
263
263
  graph.position = np.vstack((x, y)).T
@@ -267,7 +267,7 @@ def miserables(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
267
267
  return adjacency
268
268
 
269
269
 
270
- def painters(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
270
+ def painters(metadata: bool = False) -> Union[sparse.csr_matrix, Dataset]:
271
271
  """Graph of links between some famous painters on Wikipedia.
272
272
 
273
273
  * Directed graph
@@ -312,7 +312,7 @@ def painters(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
312
312
  y = np.array(
313
313
  [0.53, 0.19, -0.71, 0.44, -0.48, -0.65, 0.69, -0.11, 0.01,
314
314
  -1., 0.49, 0.28, 0.06, 0.27])
315
- graph = Bunch()
315
+ graph = Dataset()
316
316
  graph.adjacency = adjacency
317
317
  graph.names = names
318
318
  graph.position = np.stack((x, y)).T
@@ -322,7 +322,7 @@ def painters(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
322
322
  return adjacency
323
323
 
324
324
 
325
- def hourglass(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
325
+ def hourglass(metadata: bool = False) -> Union[sparse.csr_matrix, Dataset]:
326
326
  """Hourglass graph.
327
327
 
328
328
  * Bipartite graph
@@ -342,14 +342,14 @@ def hourglass(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
342
342
  """
343
343
  biadjacency = sparse.csr_matrix(np.ones((2, 2), dtype=bool))
344
344
  if metadata:
345
- graph = Bunch()
345
+ graph = Dataset()
346
346
  graph.biadjacency = biadjacency
347
347
  return graph
348
348
  else:
349
349
  return biadjacency
350
350
 
351
351
 
352
- def star_wars(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
352
+ def star_wars(metadata: bool = False) -> Union[sparse.csr_matrix, Dataset]:
353
353
  """Bipartite graph connecting some Star Wars villains to the movies in which they appear.
354
354
 
355
355
  * Bipartite graph
@@ -380,7 +380,7 @@ def star_wars(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
380
380
  if metadata:
381
381
  villains = np.array(['Jabba', 'Greedo', 'Vader', 'Boba'])
382
382
  movies = np.array(['A New Hope', 'The Empire Strikes Back', 'Return Of The Jedi'])
383
- graph = Bunch()
383
+ graph = Dataset()
384
384
  graph.biadjacency = biadjacency
385
385
  graph.names = villains
386
386
  graph.names_row = villains
@@ -391,14 +391,12 @@ def star_wars(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
391
391
  return biadjacency
392
392
 
393
393
 
394
- def movie_actor(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
394
+ def movie_actor(metadata: bool = False) -> Union[sparse.csr_matrix, Dataset]:
395
395
  """Bipartite graph connecting movies to some actors starring in them.
396
396
 
397
397
  * Bipartite graph
398
- * 31 nodes (15 movies, 16 actors), 42 edges
399
- * 9 labels (rows)
398
+ * 32 nodes (15 movies, 17 actors), 43 edges
400
399
  * Names of movies (rows) and actors (columns)
401
- * Names of movies production company (rows)
402
400
 
403
401
  Parameters
404
402
  ----------
@@ -407,53 +405,47 @@ def movie_actor(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
407
405
 
408
406
  Returns
409
407
  -------
410
- biadjacency or graph : Union[sparse.csr_matrix, Dataset]
411
- Biadjacency matrix or graph with metadata (names).
408
+ biadjacency or dataset : Union[sparse.csr_matrix, Dataset]
409
+ Biadjacency matrix or dataset with metadata (names of movies and actors).
412
410
 
413
411
  Example
414
412
  -------
415
413
  >>> from sknetwork.data import movie_actor
416
414
  >>> biadjacency = movie_actor()
417
415
  >>> biadjacency.shape
418
- (15, 16)
416
+ (15, 17)
419
417
  """
420
418
  row = np.array(
421
419
  [0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6,
422
- 6, 6, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11,
420
+ 6, 6, 7, 7, 8, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11, 11,
423
421
  12, 12, 12, 13, 13, 14, 14])
424
422
  col = np.array(
425
423
  [0, 1, 2, 1, 2, 3, 3, 4, 5, 8, 4, 6, 0, 6, 4, 7, 4,
426
- 7, 8, 3, 8, 9, 10, 11, 12, 15, 0, 11, 12, 9, 10, 13, 5, 9, 13,
427
- 1, 9, 15, 12, 14, 11, 14])
428
- biadjacency = sparse.csr_matrix((np.ones(len(row), dtype=bool), (row, col)), shape=(15, 16))
424
+ 7, 8, 3, 8, 9, 10, 11, 12, 15, 0, 11, 12, 9, 10, 13, 16, 5, 9, 13,
425
+ 1, 9, 15, 12, 14, 14, 16])
426
+ biadjacency = sparse.csr_matrix((np.ones(len(row), dtype=bool), (row, col)), shape=(15, 17))
429
427
 
430
428
  if metadata:
431
429
  movies = np.array(
432
430
  ['Inception', 'The Dark Knight Rises', 'The Big Short', 'Drive', 'The Great Gatsby', 'La La Land',
433
431
  'Crazy Stupid Love', 'Vice', 'The Grand Budapest Hotel', 'Aviator', '007 Spectre', 'Inglourious Basterds',
434
- 'Midnight In Paris', 'Murder on the Orient Express', 'Fantastic Beasts 2'])
432
+ 'Midnight In Paris', 'Murder on the Orient Express', "Pirates of the Caribbean: At World's End"])
435
433
  actors = np.array(
436
434
  ['Leonardo DiCaprio', 'Marion Cotillard', 'Joseph Gordon Lewitt', 'Christian Bale', 'Ryan Gosling',
437
435
  'Brad Pitt', 'Carey Mulligan', 'Emma Stone', 'Steve Carell', 'Lea Seydoux', 'Ralph Fiennes', 'Jude Law',
438
- 'Willem Dafoe', 'Christophe Waltz', 'Johnny Depp', 'Owen Wilson'])
439
- graph = Bunch()
440
- graph.biadjacency = biadjacency
441
- graph.names = movies
442
- graph.names_row = movies
443
- graph.names_col = actors
444
- graph.labels = np.array([0, 0, 1, 2, 3, 2, 4, 1, 5, 0, 6, 5, 7, 8, 0])
445
- graph.labels_name = np.array(['Warner Bros', 'Plan B Entertainment', 'Marc Platt Productions', 'Bazmark Films',
446
- 'Carousel Productions', 'Babelsberg Studios', 'MGM', 'Gravier Productions',
447
- 'Genre Films'])
448
- graph.labels_row = graph.labels
449
- graph.labels_row_name = graph.labels_name
450
- graph.name = 'movie_actor'
451
- return graph
436
+ 'Willem Dafoe', 'Christophe Waltz', 'Johnny Depp', 'Owen Wilson', 'Naomie Harris'])
437
+ dataset = Dataset()
438
+ dataset.biadjacency = biadjacency
439
+ dataset.names = movies
440
+ dataset.names_row = movies
441
+ dataset.names_col = actors
442
+ dataset.name = 'movie_actor'
443
+ return dataset
452
444
  else:
453
445
  return biadjacency
454
446
 
455
447
 
456
- def art_philo_science(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]:
448
+ def art_philo_science(metadata: bool = False) -> Union[sparse.csr_matrix, Dataset]:
457
449
  """Wikipedia links between 30 articles (10 artists, 10 philosophers, 10 scientists).
458
450
 
459
451
  * Directed graph
@@ -605,7 +597,7 @@ def art_philo_science(metadata: bool = False) -> Union[sparse.csr_matrix, Bunch]
605
597
  words = np.array(
606
598
  ['contribution', 'theory', 'invention', 'time', 'modern',
607
599
  'century', 'study', 'logic', 'school', 'author', 'compose'])
608
- graph = Bunch()
600
+ graph = Dataset()
609
601
  graph.adjacency = adjacency
610
602
  graph.names = names
611
603
  graph.position = position
@@ -82,6 +82,9 @@ class BaseEmbedding(Algorithm, ABC):
82
82
  self.embedding_row_ = None
83
83
  self.embedding_col_ = None
84
84
 
85
+ def _check_fitted(self):
86
+ return self.embedding_ is not None
87
+
85
88
  def _split_vars(self, shape):
86
89
  """Split labels_ into labels_row_ and labels_col_"""
87
90
  n_row = shape[0]
@@ -146,29 +146,3 @@ class LouvainEmbedding(BaseEmbedding):
146
146
  self.embedding_col_ = embedding_col.toarray()
147
147
 
148
148
  return self
149
-
150
- def predict(self, adjacency_vectors: Union[sparse.csr_matrix, np.ndarray]) -> np.ndarray:
151
- """Predict the embedding of new rows, defined by their adjacency vectors.
152
-
153
- Parameters
154
- ----------
155
- adjacency_vectors :
156
- Adjacency row vectors.
157
- Array of shape (n_col,) (single vector) or (n_vectors, n_col)
158
-
159
- Returns
160
- -------
161
- embedding_vectors : np.ndarray
162
- Embedding of the nodes.
163
- """
164
- self._check_fitted()
165
- if self.embedding_col_ is not None:
166
- n = len(self.embedding_col_)
167
- else:
168
- n = len(self.embedding_)
169
-
170
- adjacency_vectors = check_adjacency_vector(adjacency_vectors, n)
171
- check_nonnegative(adjacency_vectors)
172
- membership = get_membership(self.labels_)
173
-
174
- return normalize(adjacency_vectors).dot(membership)
@@ -277,10 +277,6 @@ class SVD(GSVD):
277
277
  factor_singular=factor_singular, factor_row=0., factor_col=0., normalized=normalized,
278
278
  solver=solver)
279
279
 
280
- @staticmethod
281
- def _check_adj_vector(adjacency_vectors: np.ndarray):
282
- return
283
-
284
280
 
285
281
  class PCA(SVD):
286
282
  """Graph embedding by Principal Component Analysis of the adjacency or biadjacency matrix.
@@ -13,16 +13,21 @@ class TestLouvainEmbedding(unittest.TestCase):
13
13
 
14
14
  def test_predict(self):
15
15
  adjacency = test_graph()
16
+ adjacency_vector = np.zeros(10, dtype=int)
17
+ adjacency_vector[:5] = 1
16
18
  louvain = LouvainEmbedding()
17
- louvain.fit(test_graph())
19
+ louvain.fit(adjacency)
18
20
  self.assertEqual(louvain.embedding_.shape[0], 10)
19
21
  louvain.fit(adjacency, force_bipartite=True)
20
22
  self.assertEqual(louvain.embedding_.shape[0], 10)
21
23
 
24
+ # bipartite
25
+ biadjacency = test_bigraph()
26
+ louvain.fit(biadjacency)
27
+ self.assertEqual(louvain.embedding_row_.shape[0], 6)
28
+ self.assertEqual(louvain.embedding_col_.shape[0], 8)
29
+
22
30
  for method in ['remove', 'merge', 'keep']:
23
31
  louvain = LouvainEmbedding(isolated_nodes=method)
24
32
  embedding = louvain.fit_transform(adjacency)
25
33
  self.assertEqual(embedding.shape[0], adjacency.shape[0])
26
-
27
-
28
-
@@ -24,6 +24,9 @@ class TestSVD(unittest.TestCase):
24
24
  self.assertEqual(gsvd.embedding_row_.shape, (n_row, min_dim))
25
25
  self.assertEqual(gsvd.embedding_col_.shape, (n_col, min_dim))
26
26
 
27
+ embedding = gsvd.predict(np.array([0, 1, 1]))
28
+ self.assertEqual(embedding.shape, (min_dim,))
29
+
27
30
  gsvd = GSVD(n_components=1, regularization=0.1, solver='lanczos')
28
31
  gsvd.fit(biadjacency)
29
32
  self.assertEqual(gsvd.embedding_row_.shape, (n_row, 1))
@@ -31,6 +34,9 @@ class TestSVD(unittest.TestCase):
31
34
  pca = PCA(n_components=min_dim, solver='lanczos')
32
35
  pca.fit(biadjacency)
33
36
  self.assertEqual(pca.embedding_row_.shape, (n_row, min_dim))
37
+ pca = PCA(n_components=min_dim, solver=LanczosSVD())
38
+ pca.fit(biadjacency)
39
+ self.assertEqual(pca.embedding_row_.shape, (n_row, min_dim))
34
40
 
35
41
  svd = SVD(n_components=min_dim, solver=LanczosSVD())
36
42
  svd.fit(biadjacency)
@@ -93,7 +93,7 @@ class GNNClassifier(BaseGNN):
93
93
  >>> features = adjacency.copy()
94
94
  >>> gnn = GNNClassifier(dims=1, early_stopping=False)
95
95
  >>> labels_pred = gnn.fit_predict(adjacency, features, labels, random_state=42)
96
- >>> np.round(np.mean(labels_pred == labels_true), 2)
96
+ >>> round(np.mean(labels_pred == labels_true), 2)
97
97
  0.88
98
98
  """
99
99
 
@@ -128,21 +128,23 @@ class LouvainIteration(BaseHierarchy):
128
128
  tree.append(self._recursive_louvain(adjacency_cluster, depth - 1, nodes_cluster))
129
129
  return tree
130
130
 
131
- def fit(self, input_matrix: Union[sparse.csr_matrix, np.ndarray]) -> 'LouvainIteration':
131
+ def fit(self, input_matrix: Union[sparse.csr_matrix, np.ndarray], force_bipartite: bool = False) \
132
+ -> 'LouvainIteration':
132
133
  """Fit algorithm to data.
133
134
 
134
135
  Parameters
135
136
  ----------
136
137
  input_matrix : sparse.csr_matrix, np.ndarray
137
138
  Adjacency matrix or biadjacency matrix of the graph.
139
+ force_bipartite :
140
+ If ``True``, force the input matrix to be considered as a biadjacency matrix.
138
141
 
139
142
  Returns
140
143
  -------
141
144
  self: :class:`LouvainIteration`
142
145
  """
143
146
  self._init_vars()
144
- input_matrix = check_format(input_matrix)
145
- adjacency, self.bipartite = get_adjacency(input_matrix)
147
+ adjacency, self.bipartite = get_adjacency(input_matrix, force_bipartite=force_bipartite)
146
148
  tree = self._recursive_louvain(adjacency, self.depth)
147
149
  dendrogram, _ = get_dendrogram(tree)
148
150
  dendrogram = np.array(dendrogram)
@@ -243,21 +245,23 @@ class LouvainHierarchy(BaseHierarchy):
243
245
  labels_unique = np.unique(labels)
244
246
  return tree
245
247
 
246
- def fit(self, input_matrix: Union[sparse.csr_matrix, np.ndarray]) -> 'LouvainHierarchy':
248
+ def fit(self, input_matrix: Union[sparse.csr_matrix, np.ndarray], force_bipartite: bool = False) \
249
+ -> 'LouvainHierarchy':
247
250
  """Fit algorithm to data.
248
251
 
249
252
  Parameters
250
253
  ----------
251
254
  input_matrix : sparse.csr_matrix, np.ndarray
252
255
  Adjacency matrix or biadjacency matrix of the graph.
256
+ force_bipartite :
257
+ If ``True``, force the input matrix to be considered as a biadjacency matrix.
253
258
 
254
259
  Returns
255
260
  -------
256
261
  self: :class:`LouvainHierarchy`
257
262
  """
258
263
  self._init_vars()
259
- input_matrix = check_format(input_matrix)
260
- adjacency, self.bipartite = get_adjacency(input_matrix)
264
+ adjacency, self.bipartite = get_adjacency(input_matrix, force_bipartite=force_bipartite)
261
265
  tree = self._get_hierarchy(adjacency)
262
266
  dendrogram, _ = get_dendrogram(tree)
263
267
  dendrogram = np.array(dendrogram)