<commit_before>import graph_tool.all as graphtool


# - connected components (properties.ConnectedComponents, properties.ParallelConnectedComponents)

class Algo:
	""" runner for an algorithm"""
	def run(self, G):
		raise Exception("Not implemented")

	def loadGraph(self, path):
		G = graphtool.load_graph(path, fmt="gml")
		return G

class bConnectedComponents(Algo):
	name = "ConnectedComponents"

	def run(self, G):
		cc = graphtool.label_components(G)



# - k-core decomposition (properties.CoreDecomposition)

class bCoreDecomposition(Algo):
	name = "CoreDecomposition"

	def run(self, G):
		cd = graphtool.kcore_decomposition(G)

# - degree distribution power-law estimation (properties.powerLawExponent)

# class bPowerLaw(Algo) – not found in GT

# - degree assortativity (properties.degreeAssortativity)

class bDegreeAssortativity(Algo):
	name = "DegreeAssortativity"

	def run(self, G):
		graphtool.assortativity(G, deg="total")


# - BFS & Dijkstra (graph.BFS, graph.Dijkstra)
class bBFS(Algo):
	name = "BFS"

	def run(self, G):
		gt.shortest_distance(G) # Johnson’s algorithm seems to be used https://graph-tool.skewed.de/static/doc/topology.html#graph_tool.topology.shortest_distance


# - community detection (community.PLM, community.PLP)

class bCommunityDetectionLM(Algo):
	name = "CommunityDetectionLM"

	def run(self, G):
		plm = networkit.community.PLM(G)
		plm.run()

class bCommunityDetectionLP(Algo):
	name = "CommunityDetectionLP"

	def run(self, G):
		plm = networkit.community.PLP(G)
		plm.run()

# - diameter, exact (properties.Diameter.exactDiameter) and estimate (properties.Diameter.estimatedDiameterRange)

class bDiameter(Algo):
	name = "Diameter"

	def run(self, G):
		d = graphtool.distance_histogram(G)


class bDiameterEstimate(Algo):
	name = "Diameter"

	def run(self, G):
		d = graphtool.pseudo_diameter(G)

# - clustering coefficients (average local), exact (properties.ClusteringCoefficient.avgLocal) and approximated (properties.ClusteringCoefficient.approxAvgLocal)<commit_msg>graphtool benchmark - fixed BFS, removed community methods<commit_after>import graph_tool.all as graphtool


# - connected components (properties.ConnectedComponents, properties.ParallelConnectedComponents)

class Algo:
	""" runner for an algorithm"""
	def run(self, G):
		raise Exception("Not implemented")

	def loadGraph(self, path):
		G = graphtool.load_graph(path, fmt="gml")
		return G

class bConnectedComponents(Algo):
	name = "ConnectedComponents"

	def run(self, G):
		cc = graphtool.label_components(G)



# - k-core decomposition (properties.CoreDecomposition)

class bCoreDecomposition(Algo):
	name = "CoreDecomposition"

	def run(self, G):
		cd = graphtool.kcore_decomposition(G)

# - degree distribution power-law estimation (properties.powerLawExponent)

# class bPowerLaw(Algo) – not found in GT

# - degree assortativity (properties.degreeAssortativity)

class bDegreeAssortativity(Algo):
	name = "DegreeAssortativity"

	def run(self, G):
		graphtool.assortativity(G, deg="total")


# - BFS & Dijkstra (graph.BFS, graph.Dijkstra)
class bBFS(Algo):
	name = "BFS"

	def run(self, G):
		from random import randint

		v = randint(0, G.num_vertices()-1)
		graphtool.bfs_search(G,v)

# - community detection (community.PLM, community.PLP)

#class bCommunityDetectionLM(Algo): – not implemented in graph-tool

#class bCommunityDetectionLP(Algo): – not implemented in graph-tool

# - diameter, exact (properties.Diameter.exactDiameter) and estimate (properties.Diameter.estimatedDiameterRange)

class bDiameter(Algo):
	name = "Diameter"

	def run(self, G):
		d = graphtool.distance_histogram(G)


class bDiameterEstimate(Algo):
	name = "Diameter"

	def run(self, G):
		d = graphtool.pseudo_diameter(G)

# - clustering coefficients (average local), exact (properties.ClusteringCoefficient.avgLocal) and approximated (properties.ClusteringCoefficient.approxAvgLocal)
{'fraction_non_alphanumeric': 0.11344969199178645, 'fraction_numerical': 0.000513347022587269, 'mean_word_length': 5.495, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6046966', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1304, 'n_words': 297}