Beispiel #1
0
    def test__liteqclass(self):
        u = 1
        set_of_u_1 = zkl.load("{}/liteqclass_output_n_5_u_1.zkl".format(self._ABS_PATH))
        g2 = bfutils.undersample(self._G, u)
        s = ur.liteqclass(g2, verbose=False, capsize=1000)
        self.assertEqual(s, set_of_u_1)

        u = 2
        set_of_u_2 = zkl.load("{}/liteqclass_output_n_5_u_2.zkl".format(self._ABS_PATH))
        g2 = bfutils.undersample(self._G, u)
        s = ur.liteqclass(g2, verbose=False, capsize=1000)
        self.assertEqual(s, set_of_u_2)
Beispiel #2
0
from gunfolds.tools.bfutils import undersample
from gunfolds.tools import ecj
from gunfolds.tools.testgraphs import *
from gunfolds.tools import zickle
import igraph
import numpy as np
import os
import scipy
import StringIO

DIR_NAME = os.path.dirname(__file__)
ABS_PATH = os.path.abspath(os.path.join(DIR_NAME))
colors = zickle.load('{}/../data/colors.zkl'.format(ABS_PATH))


def graph2dict(g):
    D = {}`
    for v in range(0, len(g.vs)):
        D[g.vs[v]["label"]] = {}
        for u in g.neighbors(v, mode="OUT"):
            D[g.vs[v]["label"]][g.vs[u]["label"]] = set([(0, 1)])
    return D


def paintSCC(g, cm):
    nameidx = {}
    D = graph2dict(g)
    scc = ecj.scc(D)
    for i in range(0, len(scc)):
        for v in scc[i]:
            g.vs[g.vs['label'].index(v)]["color"] = cm[i]
    for k in keys:
        c[k] = len(np.where(eqc == k)[0])
    return c
    

if __name__ == '__main__':

    import sys
    sys.path.append('/na/homes/splis/soft/src/dev/tools/stackedBarGraph/')
    from stackedBarGraph import StackedBarGrapher
    SBG = StackedBarGrapher()

    fig = pl.figure(figsize=[10, 1.3])
    # Read in data & create total column

    d = zkl.load("hooke_nodes_6_g32g1_.zkl")  # hooke_nodes_35_newp_.zkl")
    densities = np.sort(d.keys())

    # unique size
    usz = set()
    dc = {}
    for u in densities:
        dc[u] = get_counts(d[u])
        for v in dc[u]:
            usz.add(v)

    for u in densities:
        for c in usz:
            if not c in dc[u]:
                dc[u][c] = 0
Beispiel #4
0
def listplot(fname, mname='JJ', stl='', width=5):
    l = zkl.load(fname)
    y = min(width, len(l))
    x = np.int(np.ceil(len(l) / float(y)))
    d2l.matrix_list(l, y, x, R=2, w_gap=1, h_gap=2, mname=mname, stl=stl)
Beispiel #5
0
def timesfromfile(fname):
    d = zkl.load(fname)
    return getalltimes(d)
Beispiel #6
0
def loadgraphs(fname):
    g = zkl.load(fname)
    return g
Beispiel #7
0
def gettimes(d):
    t = [x['ms'] for x in d]
    time = map(lambda x: x / 1000. / 60., t)
    return time

l = ['leibnitz_nodes_15_density_0.1_newp_.zkl',
     'leibnitz_nodes_20_density_0.1_newp_.zkl',
     'leibnitz_nodes_25_density_0.1_newp_.zkl',
     'leibnitz_nodes_30_density_0.1_newp_.zkl',
     'leibnitz_nodes_35_density_0.1_newp_.zkl']

if __name__ == '__main__':

    alltimes_new = []
    for fname in l:
        d = zkl.load(fname)
        alltimes_new.append(gettimes(d))

    shift = 0.15
    wds = 0.3
    fliersz = 2
    lwd = 1

    plt.figure(figsize=[10, 2])

    g = sb.boxplot(alltimes_new, names=map(lambda x: str(int(x * 100)) + "",
                                           densities),
                   widths=wds, color="Reds", fliersize=fliersz,
                   linewidth=lwd,
                   **{'positions': np.arange(len(densities)) + shift,
                      'label': 'MSL'})
    import sys
    import os
    sys.path.append(os.path.expanduser(SBDIR))
    from stackedBarGraph import StackedBarGrapher
    SBG = StackedBarGrapher()

    l = [(0.15, 'leibnitz_nodes_15_density_0.1_newp_.zkl'),
         (0.20, 'leibnitz_nodes_20_density_0.1_newp_.zkl'),
         (0.25, 'leibnitz_nodes_25_density_0.1_newp_.zkl'),
         (0.30, 'leibnitz_nodes_30_density_0.1_newp_.zkl'),
         (0.35, 'leibnitz_nodes_35_density_0.1_newp_.zkl')]

    fig = pl.figure(figsize=[10, 3])
    # Read in data & create total column

    d = zkl.load("hooke_nodes_6_g32g1_.zkl")  # hooke_nodes_35_newp_.zkl")
    densities = [.15, .20, .25, .30, .35]
    d = {}
    for fname in l:
        d[fname[0]] = zkl.load(fname[1])

    # unique size
    usz = set()
    dc = {}
    for u in densities:
        dc[u] = get_counts(d[u])
        for v in dc[u]:
            usz.add(v)

    for u in densities:
        for c in usz: