Exemple #1
0
 def execute_second(self):
     numbers = []
     for i in self.prob_crescenti:
         g = Graph(self.grandezza_fissata)
         m = g.matrice_adiacenza(i)
         n, _ = SCC(m).scc()
         numbers.append(n)
     return numbers
Exemple #2
0
 def execute_fourth(self):
     tempi = []
     for i in self.grandezze_crescenti:
         g = Graph(i)
         m = g.matrice_adiacenza(self.prob_fissata)
         start = timer()
         _, _ = SCC(m).scc()
         end = timer()
         tempi.append(end-start)
     return tempi
Exemple #3
0
    def execute_third(self):
        grandezze = []
        for i in self.grandezze_crescenti:
            g = Graph(i)
            m = g.matrice_adiacenza(self.prob_fissata)
            _, d = SCC(m).scc()

            grandezza_max = 1
            for j in range(len(d)):
                if len(d[j]) > grandezza_max:
                    grandezza_max = len(d[j])
            grandezze.append(grandezza_max)

        return grandezze
Exemple #4
0
def main(argv):
    upper = 1.0
    lower = 0.1
    num_rounds = 50
    X = np.random.randn(100, 5)
    graph = graph_from_vectors(X, k=25, batch_size=5000)
    taus = np.geomspace(start=upper, stop=lower, num=num_rounds)
    scc = SCC(graph, num_rounds, taus)
    scc.fit()

    # How to inspect this?
    # this gives the things stored in the 3rd round of the alg.  (0 based)
    print('Third round of the alg: ')
    print(scc.rounds[3].__dict__)

    # the cluster assignment of the 18th point of the dataset. (0 based)
    print('cluster assignment of the 18th point of the dataset')
    print('scc.rounds[3].cluster_assignments[18]')
    print(scc.rounds[3].cluster_assignments[18])

    # the id of the parent in the next round of node 0 (0 based)
    print('the id of the parent in the next round of node 0 (0 based)')
    print('scc.rounds[3].parents[0]')
    print(scc.rounds[3].parents[0])
Exemple #5
0
    def execute_fifth(self):
        for i in [5, 10, 15, 20, 25, 30, 35, 40]:
            scc = []
            vol = []
            g = Graph(i)

            for j in range(0, 11, 1):
                m = g.matrice_adiacenza(j)
                n, d = SCC(m).scc()

                grandezza_max = 1
                for a in range(len(d)):
                    if len(d[a]) > grandezza_max:
                        grandezza_max = len(d[a])

                scc.append(grandezza_max)
                vol.append(grandezza_max)

            # Stampa sequenza di valori separati da &, utile per tabella LaTeX
            print ' & '.join([str(a) for a in scc])
            print ' & '.join([str(a) for a in vol])
Exemple #6
0
    conn.execute('INSERT INTO bc (file, scc, effective) VALUES ("%s", 0, %d)' %
                 (bc, effective))
    bc_id[bc] = next_id
    next_id = next_id + 1

deps = set()
succs = collections.defaultdict(lambda: [])
for k, v in used_in.items():
    if not defined_in.has_key(k):
        continue
    definer = bc_id[defined_in[k]]
    for u in v:
        user = bc_id[u]
        deps.add((definer, user))
        succs[definer].append(user)

for dep in deps:
    conn.execute('INSERT INTO dep VALUES (%d, %d)' % dep)

s = SCC(int, lambda i: succs[i])
sccs = s.getsccs(range(0, next_id))

sccid = 1
for scc in sccs:
    for v in scc:
        conn.execute('UPDATE bc SET scc = %d WHERE id = %d' % (sccid, v))
    sccid = sccid + 1

conn.commit()
from graph import Graph
from digraph import Digraph
from depthFirstPaths import DepthFirstPaths
from breadthFirstPaths import BreadthFirstPaths
from cc import CC
from scc import SCC
g = Digraph('anotherTest.txt')
g.show()
"""
print 'Degree of vertices'
for x in range(1,g.vertices()+1):
    print x,'->',len(g.adj(x))

print 'DFS'
d = DepthFirstPaths(g,1)
for i in range(1,g.vertices()+1):
	print i,'->',d.pathTo(i)

print 'BFS'
b = BreadthFirstPaths(g,1)
for i in range(1,g.vertices()+1):
    print i,'->',b.pathTo(i)
"""
print 'SCC'

scc = SCC(g)
for i in range(1, g.vertices() + 1):
    print i, '->', scc.id[i]