File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed
Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -478,9 +478,26 @@ def _community_fluid_communities(graph, no_of_communities):
478478 greater than 0 and fewer than number of vertices in the graph.
479479 @return: an appropriate L{VertexClustering} object.
480480 """
481+ # Validate input parameters
482+ if no_of_communities <= 0 :
483+ raise ValueError ("no_of_communities must be greater than 0" )
484+
485+ if no_of_communities >= graph .vcount ():
486+ raise ValueError ("no_of_communities must be fewer than the number of vertices" )
487+
488+ # Check if graph is weighted (not supported)
489+ if graph .is_weighted ():
490+ raise ValueError ("Weighted graphs are not supported by the fluid communities algorithm" )
491+
492+ # Handle directed graphs - the algorithm works on undirected graphs
493+ # but can accept directed graphs (they are treated as undirected)
481494 if graph .is_directed ():
482- # The C implementation will show a warning, but we can handle it here
483- pass
495+ import warnings
496+ warnings .warn (
497+ "Directed graphs are treated as undirected in the fluid communities algorithm" ,
498+ UserWarning ,
499+ stacklevel = 2
500+ )
484501
485502 membership = GraphBase .community_fluid_communities (graph , no_of_communities )
486503 return VertexClustering (graph , membership )
You can’t perform that action at this time.
0 commit comments