Skip to content
Snippets Groups Projects
Commit abb283d3 authored by Jarrod Pas's avatar Jarrod Pas
Browse files

kids.cache is actually slower than recomputing

parent 77054993
No related branches found
No related tags found
1 merge request!3Version 0.2
from itertools import product from itertools import product
import networkx as nx import networkx as nx
from kids.cache import cache
from pydtn.core import TickProcess from pydtn.core import TickProcess
...@@ -62,7 +61,6 @@ class EpochCommunity(TickProcess): ...@@ -62,7 +61,6 @@ class EpochCommunity(TickProcess):
self.get_ncf.cache_clear() self.get_ncf.cache_clear()
self.get_cbc.cache_clear() self.get_cbc.cache_clear()
@cache
def get_ld(self, x): def get_ld(self, x):
'''''' ''''''
g = self.old_graph g = self.old_graph
...@@ -75,12 +73,10 @@ class EpochCommunity(TickProcess): ...@@ -75,12 +73,10 @@ class EpochCommunity(TickProcess):
if y in g[x] and g[x][y]['duration'] > 0 if y in g[x] and g[x][y]['duration'] > 0
] ]
@cache
def get_lp(self, x): def get_lp(self, x):
'''local popularity of a node''' '''local popularity of a node'''
return sum(self.get_ld(x)) return sum(self.get_ld(x))
@cache
def get_gp(self, node): def get_gp(self, node):
'''global popularity of a node''' '''global popularity of a node'''
if node not in self.old_graph: if node not in self.old_graph:
...@@ -93,12 +89,10 @@ class EpochCommunity(TickProcess): ...@@ -93,12 +89,10 @@ class EpochCommunity(TickProcess):
if other not in community if other not in community
]) ])
@cache
def get_ui(self, x): def get_ui(self, x):
'''unique interactions with a node''' '''unique interactions with a node'''
return len(self.get_ld(x)) return len(self.get_ld(x))
@cache
def get_cbc(self, c_x, c_y): def get_cbc(self, c_x, c_y):
'''''' ''''''
if c_x == c_y: if c_x == c_y:
...@@ -110,7 +104,6 @@ class EpochCommunity(TickProcess): ...@@ -110,7 +104,6 @@ class EpochCommunity(TickProcess):
if x in g and y in g[x] if x in g and y in g[x]
]) ])
@cache
def get_ncf(self, x, c_y): def get_ncf(self, x, c_y):
'''''' ''''''
g = self.old_graph g = self.old_graph
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment