Exemple #1
0
def run_test(graph, k):
    """
    Simply runs the new code for a given graph and a given graphlet size.
    """
    lift_unordered = lt.Lift(graph, k, lift_type="unordered")
    graphlet_counts = lift_unordered.get_graphlet_count(
        num_steps=NUM_STEPS)

    return graphlet_counts
Exemple #2
0
# lift_operator.py

import lift

# lift 객체 생성
my_lift = lift.Lift()

# lift가 위치한 층 찾기
floor = my_lift.get_floor()
print("lift가 새로운 층으로 이동했습니다", floor)

# 새로운 층으로 lift 이동
my_lift.move_to_floor(5)

# 현재 lift가 위치한 층 찾기
floor = my_lift.get_floor()
print("lift가 새로운 층으로 이동했습니다", floor)
Exemple #3
0
def test_graph(graph):
    """
    Tests that the sampling method obtains correct counts for the path graph,
    wheel graph, and ladder graph (see networkx documentation for graph
    details). Large scale test that gives a basic sanity check of the whole sampling class.
    """
    if graph == "path":
        path_graph = nx.path_graph(5)
        lift_unordered = lt.Lift(path_graph, 3, lift_type="unordered")
        graphlet_counts = lift_unordered.get_graphlet_count(
            num_steps=NUM_STEPS)
        assert graphlet_counts["wedge"] == 3
        assert graphlet_counts["triangle"] == 0
        lift_unordered = lt.Lift(path_graph, 2, lift_type="unordered")
        graphlet_counts = lift_unordered.get_graphlet_count(
            num_steps=NUM_STEPS)
        assert graphlet_counts["2-path"] == 4

        print("Path graph passed.")
    elif graph == "wheel":
        wheel_graph = nx.wheel_graph(6) # this is a 6-cycle with a star center node
        lift_unordered = lt.Lift(wheel_graph, 3, lift_type="unordered")
        graphlet_counts = lift_unordered.get_graphlet_count(
            num_steps=NUM_STEPS)
        assert graphlet_counts["wedge"] == 10
        assert graphlet_counts["triangle"] == 5
        lift_unordered = lt.Lift(wheel_graph, 2, lift_type="unordered")
        graphlet_counts = lift_unordered.get_graphlet_count(
            num_steps=NUM_STEPS)
        assert graphlet_counts["2-path"] == 10
        print("Wheel graph passed.")
    elif graph == "ladder":
        ladder_graph = nx.ladder_graph(4) # this is two 6-paths joined one to one
        lift_unordered = lt.Lift(ladder_graph, 3, lift_type="unordered")
        graphlet_counts = lift_unordered.get_graphlet_count(
            num_steps=NUM_STEPS)
        assert graphlet_counts["wedge"] == 16
        assert graphlet_counts["triangle"] == 0
        lift_unordered = lt.Lift(ladder_graph, 2, lift_type="unordered")
        graphlet_counts = lift_unordered.get_graphlet_count(
            num_steps=NUM_STEPS)
        assert graphlet_counts["2-path"] == 10
        print("Ladder graph passed.")
    elif graph == "bio-celegansneural":
        graphlet_counts = run_test("bio-celegansneural", 3)
        actual_triangle_count = 12.6 * 10**3 / 3
        assert ((graphlet_counts["triangle"] - actual_triangle_count)
                / actual_triangle_count < THRESHOLD)
        print(graph + " passed.")
        print(graphlet_counts, "\n")
    elif graph == "ia-email-univ":
        graphlet_counts = run_test("ia-email-univ", 3)
        actual_triangle_count = 16000 / 3
        assert ((graphlet_counts["triangle"] - actual_triangle_count)
                / actual_triangle_count < THRESHOLD)
        print(graph + " passed.")
        print(graphlet_counts, "\n")
    elif graph == "misc-fullb":
        graphlet_counts = run_test("misc-fullb", 3)
        actual_triangle_count = 180.6 * 10**6 / 3
        assert ((graphlet_counts["triangle"] - actual_triangle_count)
                / actual_triangle_count < THRESHOLD)
        print(graph + " passed.")
        print(graphlet_counts, "\n")
    elif graph == "misc-polblogs":
        graphlet_counts = run_test("misc-polblogs", 3)
        actual_triangle_count = 459.4 * 10**3 / 3
        assert ((graphlet_counts["triangle"] - actual_triangle_count)
                / actual_triangle_count < THRESHOLD)
        print(graph + " passed.")
        print(graphlet_counts, "\n")
    else:
        print("Graph unknown.")
Exemple #4
0
# # test_graph("misc-polblogs")
#
# # ICYMI: nx.star_graph(4) has 5 nodes.
# graphlet_counts = run_test(nx.star_graph(4), 5)
# assert graphlet_counts[0] == 1
# print("Star graph passed.")
#
# graphlet_counts = run_test(nx.complete_graph(5), 5)
# assert graphlet_counts[20] == 1
#
# graphlet_counts = run_test(nx.complete_graph(10), 5)
# assert graphlet_counts[20] == 252
# print("Complete graph passed.")

import time
lift = lt.Lift("bio-celegansneural", 4)
times = []
for i in range(100):
    start = time.time()
    lift.get_graphlet_count(num_steps=1)
    times.append(time.time() - start)
print(
    "Average time taken for a single iteration: ",
    sum(times)/100
    )

# # Pynauty tests.
# import networkx as nx
# import pynauty as na
#
# g = na.Graph(number_of_vertices=8, directed=False,
Exemple #5
0
leftPedestals = [[1, 2],
[5, 8],
[7, 6],
[3, 0]]

rightPedestals = [[3, 6],
[1, 0],
[5, 2],
[7, 8]]

homeMarker = [0, 21, 14, 7]

c = configReader.ConfigReader(R.usbkey, d)
v = voltaged.Voltaged(R, d)
l = lift.Lift(R)
if c.getDebug():
    f = function.Driver(R, m, c.getMaxSpeed(), c.getDistModifier(), c.getDistModifierBegin(), (c.getCamResX(), c.getCamResY()), d)
else:
    f = function.Driver(R, m, c.getMaxSpeed(), c.getDistModifier(), c.getDistModifierBegin(), (c.getCamResX(), c.getCamResY()))
    
a = anticollisiond.AntiCollisiond(R)
l.daemon = True
m.daemon = True
a.daemon = True
v.daemon = True

b = c.getTokenOrder()
command = c.getCommands()

maxSpeed = c.getMaxSpeed()
Exemple #6
0
armMotor = robot.getDevice('l5')
arm = arm.Arm(armMotor)

# arm.out()

grabConnector = robot.getDevice('connector')
# grab = grab.Grab(grabConnector )

liftMotors = []
liftMotorsNames = ['l1', 'l2', 'l3', 'l4']
for i in range(len(liftMotorsNames)):
    liftMotors.append(robot.getDevice(liftMotorsNames[i]))
    liftMotors[i].setPosition(0)

lift = lift.Lift(liftMotors)

level3 = 0.183
level3 = 0.18
lift.go(level3)

# while(not arm.isOut()):
# pass

arm.out()

while robot.step(timestep) != -1:
    if (arm.isOut()):
        print('out')
        grabConnector.enablePresence(10)
        print(grabConnector.getPresence())