# neurostatx.cli.GraphMetrics

*module*

[View source](https://github.com/gagnonanthony/NeuroStatX/blob/main/neurostatx/cli/GraphMetrics.py#L1-L1)

## neurostatx.cli.GraphMetrics.OPERATIONS

*attribute* · *module attribute*

```python
OPERATIONS = get_metrics_ops()
```

Mapping of metric names to NetworkX functions GraphMetrics can run.

[View source](https://github.com/gagnonanthony/NeuroStatX/blob/main/neurostatx/cli/GraphMetrics.py#L16-L16)

## neurostatx.cli.GraphMetrics.app

*attribute* · *module attribute*

```python
app = App(default_parameter=Parameter(negative=()))
```

Cyclopts application for the GraphMetrics command-line tool.

[View source](https://github.com/gagnonanthony/NeuroStatX/blob/main/neurostatx/cli/GraphMetrics.py#L20-L20)

## neurostatx.cli.GraphMetrics.GraphMetrics

*function*

```python
def GraphMetrics(operation: Annotated[List[str], Parameter(show_choices=True, show_default=False, group=Group(Arguments))], out_file: Annotated[str, Parameter(show_default=False, group='Essential Files Options')] = None, verbose: Annotated[bool, Parameter(-v, --verbose, group='Optional parameters')] = False, overwrite: Annotated[bool, Parameter(-f, --overwrite, group='Optional parameters')] = False)
```

Compute NetworkX metrics on an existing undirected weighted graph.

Runtime depends on hardware and the chosen metric; a large graph
(~10 000 nodes) can take about 10 minutes.

> **Notes**
>
> **Available metrics**
> 
> Available metrics come from NetworkX algorithms that can handle undirected
> weighted graphs (see the operation argument) [1]. If NODE is required,
> provide a single node label (such as ``c1``). If NODES is required, provide
> multiple nodes within quotation marks (such as ``"c1 c2 c3"``).
> 
> * eigencentrality: GRAPH WEIGHT — eigenvector centrality for all nodes.
> * closenesscentrality: GRAPH WEIGHT — closeness centrality for all nodes.
> * betweennesscentrality: GRAPH WEIGHT — betweenness centrality for all
>   nodes.
> * informationcentrality: GRAPH WEIGHT — information centrality for all
>   nodes.
> * currentflowbc: GRAPH WEIGHT — current flow betweenness centrality for
>   all nodes.
> * loadcentrality: GRAPH WEIGHT — load centrality for all nodes.
> * harmoniccentrality: GRAPH WEIGHT — harmonic centrality for all nodes.
> * eccentricity: GRAPH WEIGHT — eccentricity for all nodes.
> * clustering: GRAPH WEIGHT — clustering coefficient for all nodes.
> * constraint: GRAPH NODES WEIGHT — constraint for all specified nodes.
> * effectivesize: GRAPH NODES WEIGHT — effective size for all specified
>   nodes.
> * closenessvitality: GRAPH NODE WEIGHT — closeness vitality for a single
>   node.
> * degree: GRAPH WEIGHT — degree of the specified node.

> **References**
>
> [1] [NetworkX
> algorithms](https://networkx.org/documentation/stable/reference/algorithms/index.html#)

**Parameters**

- `operation` (`List[str]`) — List of arguments to provide to the script. The first argument is the operation to perform. The second argument is the input graph file. The rest of the arguments are the arguments required by the operation (see above).
- `out_file` (`str`) (default: `None`) — Path and name of the file containing the metrics for each node. Defaults to ``./operation_name.xlsx``.
- `verbose` (`bool`) (default: `False`) — If true, produce verbose output. Defaults to False.
- `overwrite` (`bool`) (default: `False`) — If true, force overwriting of existing output files. Defaults to False.

**Examples**

```bash
GraphMetrics --out-folder output/ eigencentrality graph.gexf membership
```

[View source](https://github.com/gagnonanthony/NeuroStatX/blob/main/neurostatx/cli/GraphMetrics.py#L24-L178)
