Skip to content

Commit

Permalink
Merge pull request #1053 from PetholzA/feature/documentation_angus
Browse files Browse the repository at this point in the history
Python documentation: fixes inconsistencies, typos
  • Loading branch information
fabratu committed May 23, 2023
2 parents 01b3f2b + a64dea9 commit 68f89a2
Show file tree
Hide file tree
Showing 21 changed files with 151 additions and 99 deletions.
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@

# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".

html_title = None

html_add_permalinks = None
Expand Down Expand Up @@ -318,4 +319,4 @@

# -- Options for Bibtex output -------------------------------------------------

bibtex_bibfiles = ['refs.bib']
bibtex_bibfiles = ['refs.bib']
8 changes: 4 additions & 4 deletions include/networkit/graph/Graph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2088,7 +2088,7 @@ class Graph final {
* Get an iterable range over the neighbors of @a.
*
* @param u Node.
* @return Iterator range over the neighbors of @a.
* @return Iterator range over the neighbors of @a u.
*/
NeighborRange<false> neighborRange(node u) const {
assert(exists[u]);
Expand All @@ -2100,7 +2100,7 @@ class Graph final {
* weights.
*
* @param u Node.
* @return Iterator range over pairs of neighbors of @a and corresponding
* @return Iterator range over pairs of neighbors of @a u and corresponding
* edge weights.
*/
NeighborWeightRange<false> weightNeighborRange(node u) const {
Expand All @@ -2113,7 +2113,7 @@ class Graph final {
* Get an iterable range over the in-neighbors of @a.
*
* @param u Node.
* @return Iterator range over pairs of in-neighbors of @a.
* @return Iterator range over pairs of in-neighbors of @a u.
*/
NeighborRange<true> inNeighborRange(node u) const {
assert(isDirected());
Expand All @@ -2126,7 +2126,7 @@ class Graph final {
* edge weights.
*
* @param u Node.
* @return Iterator range over pairs of in-neighbors of @a and corresponding
* @return Iterator range over pairs of in-neighbors of @a u and corresponding
* edge weights.
*/
NeighborWeightRange<true> weightInNeighborRange(node u) const {
Expand Down
16 changes: 7 additions & 9 deletions networkit/algebraic.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,12 @@ def laplacianMatrix(G):
Parameters
----------
G : networkit.Graph
The input graph.
The graph.
Returns
-------
ndarray or :py:class:`scipy.sparse.csr_matrix`
The N x N laplacian matrix of csgraph. It will be a NumPy array (dense) if the input was dense, or a sparse matrix otherwise.
ndarray
The length-N diagonal of the Laplacian matrix. For the normalized Laplacian, this is the array of square roots of vertex degrees or 1 if the degree is zero.
:py:class:`scipy.sparse.csr_matrix`
The N x N laplacian matrix of csgraph. It will be a scipy.sparse.csr_matrix.
"""
A = adjacencyMatrix(G)
return scipy.sparse.csgraph.laplacian(A)
Expand Down Expand Up @@ -225,7 +223,7 @@ def laplacianEigenvectors(G, cutoff=-1, reverse=False):
Parameters
----------
G : networkit.graph
G : networkit.Graph
The input graph.
cutoff : int, optional
The maximum (or minimum) number of eigenvectors needed. Default: -1
Expand All @@ -252,7 +250,7 @@ def adjacencyEigenvectors(G, cutoff=-1, reverse=False):
Parameters
----------
G : networkit.graph
G : networkit.Graph
The graph.
cutoff : int, optional
The maximum (or minimum) number of eigenvectors needed. Default: -1
Expand All @@ -279,7 +277,7 @@ def laplacianEigenvector(G, i, reverse=False):
Parameters
----------
G : networkit.graph
G : networkit.Graph
The input graph.
i : int
Computes the eigenvector and value of index i.
Expand Down Expand Up @@ -307,7 +305,7 @@ def adjacencyEigenvector(G, i, reverse=False):
Parameters
----------
G : networkit.graph
G : networkit.Graph
The input graph.
i : int
Computes the eigenvector and value of index i.
Expand Down
26 changes: 13 additions & 13 deletions networkit/centrality.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ cdef class Centrality(Algorithm):
Returns
-------
dict(tuple(int, float))
A vector of pairs sorted into descending order. Each pair contains a node and the corresponding score
list(tuple(int, float))
A list of pairs sorted into descending order. Each pair contains a node and the corresponding score
"""
if self._this == NULL:
raise RuntimeError("Error, object not properly initialized")
Expand Down Expand Up @@ -193,13 +193,13 @@ cdef class ApproxBetweenness(Centrality):
G : networkit.Graph
The input graph
epsilon : double, optional
Maximum additive error
Maximum additive error. Default: 0.01
delta : double, optional
Probability that the values are within the error guarantee
Probability that the values are within the error guarantee. Default: 0.1
universalConstant: double, optional
The universal constant to be used in computing the sample size.
It is 1 by default. Some references suggest using 0.5, but there
is no guarantee in this case.
is no guarantee in this case. Default: 1.0
"""

def __cinit__(self, Graph G, epsilon=0.01, delta=0.1, universalConstant=1.0):
Expand Down Expand Up @@ -257,7 +257,7 @@ cdef extern from "<networkit/centrality/KadabraBetweenness.hpp>":

cdef class KadabraBetweenness(Algorithm):
"""
KadabraBetweenness(Graph G, err = 0.01, delta = 0.1, k = 0, unionSample = 0, startFactor = 100
KadabraBetweenness(Graph G, err = 0.01, delta = 0.1, k = 0, unionSample = 0, startFactor = 100)
Approximation of the betweenness centrality and computation of the top-k
nodes with highest betweenness centrality according to the algorithm
Expand Down Expand Up @@ -773,7 +773,7 @@ cdef extern from "<networkit/centrality/Closeness.hpp>":

cdef class Closeness(Centrality):
"""
Closeness(G, normalized, checkConnectdedness)
Closeness(G, normalized, checkConnectedness)
Closeness(G, normalized, variant)
Constructs the Closeness class for the given Graph `G`. If the Closeness scores should not be normalized,
Expand All @@ -792,16 +792,16 @@ cdef class Closeness(Centrality):
normalized : bool
Set this parameter to False if scores should not be normalized into an interval of [0,1].
Normalization only works for unweighted graphs.
checkConnectdedness : bool
checkConnectedness : bool
Set this parameter to True to also check if the graph is connected before computing closeness.
Set this parameter to False to not check if the graph is connected (note: the standard definition
of closeness works for connected graphs, choose this if the input graph is known to be connected).
ClosenessVariant : networkit.centrality.ClosenessVariant
Set this parameter to networkit.centrality.ClosenessVariant.Standard to use the standard
definition of closeness, that is defined for connected graphs only; in this case, checkConnectdedness
definition of closeness, that is defined for connected graphs only; in this case, checkConnectedness
is automatically set to True.
Set this parameter to networkit.centrality.ClosenessVariant.Generalized to use the generalized
definition of closeness, that is defined for also non-connected graphs; in this case, checkConnectdedness
definition of closeness, that is defined for also non-connected graphs; in this case, checkConnectedness
is automatically set to False.
"""

Expand Down Expand Up @@ -2654,10 +2654,10 @@ cdef class ApproxElectricalCloseness(Centrality):
G : networkit.Graph
The input graph.
eps : float, optional
Maximum absolute error of the elements in the diagonal.
Maximum absolute error of the elements in the diagonal. Default: 0.1
kappa : float, optional
Balances the tolerance of the solver for the linear system and the
number of USTs to be sampled.
number of USTs to be sampled. Default: 0.3
"""

def __cinit__(self, Graph G, double eps = 0.1, double kappa = 0.3):
Expand Down Expand Up @@ -2688,7 +2688,7 @@ cdef class ApproxElectricalCloseness(Centrality):
Parameters
----------
tol : float
Tolerance for the LAMG solver.
Tolerance for the LAMG solver. Default: 1e-9
Returns
-------
Expand Down
17 changes: 11 additions & 6 deletions networkit/community.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -236,17 +236,17 @@ cdef extern from "<networkit/community/GraphClusteringTools.hpp>" namespace "Net

cdef class GraphClusteringTools:
@staticmethod
def getImbalance(Partition zeta, Graph graph = None):
def getImbalance(Partition zeta, Graph G = None):
"""
getImbalance(zeta)
getImbalance(zeta, G)
Get the imbalance of clusters in the given partition.
Parameters
----------
zeta : networkit.Partition
The first partition.
graph : networkit.Graph, optional
G : networkit.Graph, optional
The input graph to compare the imbalance to. Default: None
Returns
Expand All @@ -255,7 +255,7 @@ cdef class GraphClusteringTools:
Imbalance of the partition.
"""
if graph is not None:
return getImbalance(zeta._this, graph._this)
return getImbalance(zeta._this, G._this)
else:
return getImbalance(zeta._this)

Expand Down Expand Up @@ -407,7 +407,10 @@ cdef class PartitionIntersection:
"""
cdef _PartitionIntersection _this
def calculate(self, Partition zeta, Partition eta):
""" Calculate the intersection of two partitions `zeta` and `eta`
"""
calculate(zeta, eta)
Calculate the intersection of two partitions `zeta` and `eta`.
Parameters
----------
Expand Down Expand Up @@ -740,7 +743,7 @@ cdef class LouvainMapEquation(CommunityDetector):
hierarchical: bool, optional
Iteratively create a graph of the locally optimal clusters and optimize locally on that graph.
maxIterations: int, optional
The maximum number of local move iterations.
The maximum number of local move iterations. Default: 32
parallelizationStrategy: str, optional
Parallelization strategy, possible values: "relaxmap", "synchronous", "none". Default: "relaxmap"
"""
Expand Down Expand Up @@ -771,6 +774,8 @@ cdef class PLP(CommunityDetector):
The graph on which the algorithm has to run.
updateThreshold : int, optional
number of nodes that have to be changed in each iteration so that a new iteration starts. Default: None
maxIterations: int, optional
The maximum number of local move iterations. Default: None
baseClustering : networkit.Partition, optional
PLP needs a base clustering to start from; if none is given the algorithm will
run on a singleton clustering. Default: None
Expand Down
6 changes: 3 additions & 3 deletions networkit/components.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ cdef class ConnectedComponents(ComponentDecomposition):
Parameters
----------
graph : networkit.Graph
G : networkit.Graph
The input graph.
compactGraph : bool, optional
If true, the node ids of the output graph will be compacted
Expand Down Expand Up @@ -163,13 +163,13 @@ cdef class ParallelConnectedComponents(ComponentDecomposition):
Parameters
----------
graph : networkit.Graph
G : networkit.Graph
The input graph
coarsening : bool, optional
Specifies whether the main algorithm based on label propagation (LP)
shall work recursively (true) or not (false) by coarsening/contracting
an LP-computed clustering. Defaults to true since we saw positive effects
in terms of running time for many networks. Beware of possible memory implications.
in terms of running time for many networks. Beware of possible memory implications. Default: True
"""

def __cinit__(self, Graph G, coarsening=True ):
Expand Down
2 changes: 1 addition & 1 deletion networkit/csbridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def widget_from_graph(G, node_scores = None, node_partition = None, node_palette
node_palette : list of tuples, optional
Array consisting of normalized rgb-values. If none is given, seaborn.color_palette.colors is used. Default: None
show_ids : boolean, optional
Set whether node ids should be visible in plot-widget. Is set to True by default. Default: None
Set whether node ids should be visible in plot-widget. Is set to True by default. Default: True
"""
print("WARNING: Module csbridge is deprecated and will be removed in future updates. Use networkit.vizbridges.widgetFromGraph() instead.")
return widgetFromGraph(G, nodeScores = node_scores, nodePartition = node_partition, nodePalette = node_palette, showIds = show_ids)
Loading

0 comments on commit 68f89a2

Please sign in to comment.