def __init__(self, fname, sname): super(CoreMinEdgesExperiments, self).__init__() self.fname = fname self.sname = sname self.graph = nx.read_edgelist(self.fname) self.kcore = kcore.KCore(self.graph) self.number_of_nodes = self.graph.number_of_nodes() self.number_of_edges = self.graph.number_of_edges()
def __init__(self, base, sname, adjacency=False): super(KCoreGraph, self).__init__() self.sname = sname if adjacency: self.graph = nx.read_adjlist(base) else: self.graph = nx.read_edgelist(base) self.cnumber = kcore.KCore(self.graph).coreNumber() self.top = [1, 0.2, 0.1] self.ori_graph = self.graph.copy()
def __init__(self, fname, sname, adjacency=False, ftype='file'): super(KCoreHistogram, self).__init__() self.sname = sname # do not save if sname is none if ftype == 'file': if not adjacency: self.graph = nx.read_edgelist(fname) else: self.graph = nx.read_adjlist(fname) else: self.graph = fname.copy() # fname is a networkx graph self.kcore = kcore.KCore(self.graph) print('Number of nodes: {}\t Number of edges: {}'.format(\ self.graph.number_of_nodes(), self.graph.number_of_edges()))
def __init__(self, fname, sname, adjacency=False, mode='111', ftype='file', top=None): super(KCoreExperiment, self).__init__() self.fname = fname self.sname = sname # If sname is none retults are turned not saved self.adj = adjacency """ 1st digit for random node deletion, 2nd digit for random edge deletion, 3rd digit for random rewiring preserving degree dist """ self.mode = mode if ftype == 'file': # ftype can be file on graph. if graph fname is a networkx graph object if not self.adj: self.graph = nx.read_edgelist(self.fname) self.graph.remove_edges_from(self.graph.selfloop_edges()) else: self.graph = nx.read_adjlist(self.fname) self.graph.remove_edges_from(self.graph.selfloop_edges()) self.ori_graph = None else: self.graph = fname.copy() self.ori_graph = fname.copy() self.kcore = kcore.KCore(self.graph) self.number_of_nodes = self.graph.number_of_nodes() self.number_of_edges = self.graph.number_of_edges() if top is None: self.top = [x / 100 for x in range(100, 1, -5) ] # Percentage of top nodes consider else: self.top = top self.stats = statistics.Statistics()
def __init__(self, fname, sname): super(KCoreTriangles, self).__init__() self.graph = nx.read_edgelist(fname) self.kcore = kcore.KCore(self.graph) self.top = int(self.graph.number_of_nodes() * 0.1) self.sname = sname