Skip to content

YuvalSK/graph-measures

 
 

Repository files navigation

Topological Graph Features

Topological feature calculators infrastructure.

C code

For installation and running instructions for the C code, refer to the manual.

Calculating Features

The feature calculators work on a gnx instance. At first we'll define a graph (networkx Graph) and a logger

import networkx as nx from loggers import PrintLogger gnx = nx.DiGraph() # should be a subclass of Graph gnx.add_edges_from([(0, 1), (0, 2), (1, 3), (3, 2)]) logger = PrintLogger("MyLogger")

On that graph we'll want to calculate the topological features. We can do that in 2 ways:

  • Calculate a specific feature.
import numpy as np from features_algorithms.vertices.louvain import LouvainCalculator feature = LouvainCalculator(gnx, logger=logger) feature.build() mx = feature.to_matrix(mtype=np.matrix)
  • Calculate a set of features.
import numpy as np from features_infra.graph_features import GraphFeatures from features_algorithms.vertices.louvain import LouvainCalculator from features_algorithms.vertices.betweenness_centrality import BetweennessCentralityCalculator features_meta = { "louvain": FeatureMeta(LouvainCalculator, {"lov"}), "betweenness_centrality": FeatureMeta(BetweennessCentralityCalculator, {"betweenness"}), } features = GraphFeatures(gnx, features_meta, logger=logger) features.build() mx = features.to_matrix(mtype=np.matrix)

About

Topological feature calculators infrastructure.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 73.3%
  • Python 25.5%
  • Other 1.2%