Beispiel #1
0
import sys
import numpy as np
from frovedis.exrpc.server import *
import frovedis.graph as fnx
import networkx as nx

# initializing the Frovedis server
argvs = sys.argv
argc = len(argvs)
if argc < 2:
    print(
        'Please give frovedis_server calling command as the first argument \n(e.g. "mpirun -np 2 -x /opt/nec/nosupport/frovedis/ve/bin/frovedis_server")'
    )
    quit()

fname = 'input/cit-Patents_10.txt'
FrovedisServer.initialize(argvs[1])
frov_graph = fnx.read_edgelist(fname, nodetype=np.int64)
frov_graph.debug_print()

ret = fnx.connected_components(frov_graph, print_summary=True, verbose=1)
#ret = fnx.connected_components(frov_graph)
for i in ret:
    print(i)
frov_graph.release()

# Shutting down the Frovedis server
FrovedisServer.shut_down()
        "nx_bfs_time": nx_bfs_time,
        "result_matched": result_matched
    }))
bfs_df["frov_speed_up"] = bfs_df["nx_bfs_time"] / bfs_df["frov_bfs_time"]
print(bfs_df)

# -------- connected components demo --------
frov_cc_time = []
nx_cc_time = []
frov_ncomponents = []
nx_ncomponents = []
result_matched = []

for i in range(len(frov_graph)):
    start_time = time.time()
    tmp = fnx.connected_components(frov_graph[i])
    set_cc_frov = set()
    for elem in tmp:
        set_cc_frov.add(frozenset(elem))
    frov_cc_time.append(round(time.time() - start_time, 4))
    frov_ncomponents.append(len(set_cc_frov))

    start_time = time.time()
    tmp = nx.connected_components(nx_graph[i])
    set_cc_nx = set()
    for elem in tmp:
        set_cc_nx.add(frozenset(elem))
    nx_cc_time.append(round(time.time() - start_time, 4))
    nx_ncomponents.append(len(set_cc_nx))

    result_matched.append("Yes" if set_cc_frov == set_cc_nx else "No")
Beispiel #3
0
import networkx as nx
import frovedis.graph as fnx

DATASET = "input/data"

#FROVEDIS
try:
    argvs = sys.argv
    argc = len(argvs)
    if (argc < 2):
        print ('Please give frovedis_server calling command as the first argument \n(e.g. "mpirun -np 2 -x /opt/nec/nosupport/frovedis/ve/bin/frovedis_server")')
        quit()
    FrovedisServer.initialize(argvs[1])
    
    frov_graph = fnx.read_edgelist(DATASET, nodetype=np.int32, delimiter=' ')
    fres = list(fnx.connected_components(frov_graph))
    
    FrovedisServer.shut_down()
except Exception as e:
    print ("status=Exception: " + str(e))
    sys.exit(1)

#NetworkX
try: 
    nx_graph = nx.read_edgelist(DATASET, nodetype=np.int32, delimiter=' ')
    nres = list(nx.connected_components(nx_graph))
except Exception as e:
    print ("status=Exception: " + str(e))
    sys.exit(1)
print (fres)
print (nres)