Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (15.9%) to scientific vocabulary

Keywords

graph networks python topological-graph-theory
Last synced: 6 months ago · JSON representation ·

Repository

Basic Info
  • Host: GitHub
  • Owner: AmitKabya
  • License: gpl-3.0
  • Language: C++
  • Default Branch: master
  • Homepage:
  • Size: 107 MB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 1
  • Releases: 0
Topics
graph networks python topological-graph-theory
Created almost 4 years ago · Last pushed over 3 years ago
Metadata Files
Readme License Citation

README.md

Topological Graph Features

Topological feature calculators infrastructure.

Calculating Features

This package helps one to calculate features for a given graph. All features are implemented in python codes, and some features have also an accelerated version written in C++. Among the accelerated features, one can find a code for calculating 3- and 4-motifs using VDMC, a distributed algorithm to calculate 3- and 4-motifs in a GPU-parallelized way.

Versions

  • Last version: 0.1.44
  • Last stable version: 0.1.22

What Features Can Be Calculated Here?

The set of all vertex features implemented in graph-measures is the following. The features that have an accelerated version are written in bold: * Average neighbor degree * General (i.e. degree if undirected, else or (in-degree, out-degree)) * Louvain (i.e. implement Louvain community detection method, then associate to each vertex the number of vertices in its community) * Hierarchy energy * Motifs * K core * Attraction basin * Page Rank * Fiedler vector * Closeness centrality * Eccentricity * Load centrality * BFS moments * Flow * Betweenness centrality * Communicability betweenness centrality * Eigenvector centrality * Clustering coefficient * Square clustering coefficient * Generalized degree * All pairs shortest path length * All pairs shortest path

Aside from those, there are some other edge features. Some more information regarding the features can be found in the files of features_meta.

Dependencies

requirements.txt setuptools networkx==2.6.3 pandas numpy matplotlib scipy scikit-learn python-louvain bitstring future torch

How To Use The Accelerated Version (CPU/GPU)?

Both versions currently are not supported with the pip installation. \ To use the accelerated version, one must use Linux operation system and Anaconda distribution, with the follow the next steps: 1. Go to the package's GitHub website and manually download:

  • The directory graphMeasures.
  • The python file runMakefileACC.py.

You might need to download a zip of the repository and extract the necessary files. 2. Place both the file and the directory inside your project, and run runMakefileACC.py. 3. Move to the boost environment: conda activate boost (The environment was created in step 2). 4. Use the package as explained in the section How To Use?

Installation Through pip

The full functionality of the package is currently available on a Linux machine, with a Conda environment. - Linux + Conda
1. Go to base environment
2. If pip is not installed on your env, install it. Then, use pip to install the package - Otherwise, pip must be installed. commandline pip install graph-measures Note: On Linux+Conda the installation might take longer (about 5-10 minuets) due to the compilation of the c++ files.

How To Use?

Even though one has installed the package as graph-measures, The package should be imported from the code as graphMesaures. Hence, use: python import graphMeasures

Calculating Features

There are two main methods to calculate features: 1. Using FeatureCalculator (recommended): \ A class for calculating any requested features on a given graph. \ The graph is input to this class as a text-like file of edges, with a comma delimiter, or a networkx Graph object. For example, the graph example_graph.txt is the following file: 0,1 0,2 1,3 3,2 Now, an implementation of feature calculations on this graph looks like this: python import os from graphMeasures import FeatureCalculator # set of features to be calculated feats = ["motif3", "louvain"] # path to the graph's edgelist or nx.Graph object graph = os.path.join("measure_tests", "example_graph.txt") # The path in which one would like to save the pickled features calculated in the process. dir_path = "" # More options are shown here. For infomation about them, refer to the file. ftr_calc = FeatureCalculator(path, feats, dir_path=dir_path, acc=True, directed=False, gpu=True, device=0, verbose=True) # calculate the features. If one do not want the features to be saved, # one should set the parameter 'should_dump' to False (set to True by default). ftr_calc.calculate_features() mx = ftr_calc.feature_matrix More information can be found in featuresforany_graph.py. \ Note: If one set acc=True without using a Linux+Conda machine, an exception will be thrown.\ Note: If one set gpu=True without using a Linux+Conda machine that has cuda available on it, an exception will be thrown. 2. By the calculations as below (less recommended): \ The calculations require an input graph in NetworkX format, later referred as gnx, and a logger. For this example, we build a gnx and define a logger: ```python import networkx as nx from graphMeasures.loggers import PrintLogger

gnx = nx.DiGraph() # should be a subclass of Graph gnx.addedgesfrom([(0, 1), (0, 2), (1, 3), (3, 2)])

logger = PrintLogger("MyLogger") ``` On the gnx we have, we will want to calculate the topological features. There are two options to calculate topological features here, depending on the number of features we want to calculate: * Calculate a specific feature:

```python
import numpy as np
# Import the feature. 
# If simple, import it from vertices folder, otherwise from accelerated_graph_features: 
from graphMeasures.features_algorithms.vertices.louvain import LouvainCalculator  

feature = LouvainCalculator(gnx, logger=logger)  
feature.build()  # The building happens here

mx = feature.to_matrix(mtype=np.matrix)  # After building, one can request to get features the a matrix 
```

* Calculate a set of features (one feature can as well be calculated as written here):

```python

import numpy as np from graphMeasures.featuresinfra.graphfeatures import GraphFeatures from graphMeasures.featuresinfra.featurecalculators import FeatureMeta from graphMeasures.featuresalgorithms.vertices.louvain import LouvainCalculator from graphMeasures.featuresalgorithms.vertices.betweenness_centrality import BetweennessCentralityCalculator

featuresmeta = { "louvain": FeatureMeta(LouvainCalculator, {"lov"}), "betweennesscentrality": FeatureMeta(BetweennessCentralityCalculator, {"betweenness"}), } # Hold the set of features as written here.

features = GraphFeatures(gnx, features_meta, logger=logger) features.build()

mx = features.to_matrix(mtype=np.matrix) ```

Note: All the keys-values options that can be set in the features_meta variable can be found in graphMeasures.features_meta or graphMeasures.accelerated_features_meta ```python from graphMeasures.featuresmeta import FeaturesMeta # if one uses the accelerated calculation: # from graphMeasures.acceleratedfeaturesmeta import FeaturesMeta allpossiblefeaturesmeta = FeaturesMeta().NODE_LEVEL

# all possible features print(allpossiblefeaturesmeta.keys())
# get the value for louvain louvain = all
possiblefeaturesmeta['louvain']
# get the value for betweennesscentrality betweennesscentrality = allpossiblefeaturesmeta['betweennesscentrality'] ```

Owner

  • Login: AmitKabya
  • Kind: user

Citation (CITATION.cff)

cff-version: 1.2.0
title: graph-measures
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Itay
    name-particle: Levinas
    affiliation: Bar-Ilan University
    email: levinai@biu.ac.il
  - given-names: Roy
    name-particle: Scherz
    affiliation: Bar-Ilan University
  - given-names: Yoram
    name-particle: Louzoun
    affiliation: Bar-Ilan University
    email: louzouy@math.biu.ac.il
repository-code: 'https://github.com/louzounlab/graph-measures'
abstract: >-
  This repository helps one to calculate features for
  a given graph. All features are implemented in
  python codes, and some features have also an
  accelerated version written in C++. Among the
  accelerated features, one can find a code for
  calculating 3- and 4-motifs using VDMC, a
  distributed algorithm to calculate 3- and 4-motifs
  in a GPU-parallelized way.
version: 0.1.44
date-released: '2022-10-20'

GitHub Events

Total
Last Year

Dependencies

requirements.txt pypi
  • bitstring *
  • future *
  • matplotlib *
  • networkx ==2.6.3
  • numpy *
  • pandas *
  • python-louvain *
  • scikit-learn *
  • scipy *
  • setuptools *
  • torch *