def get_graph(login_name):
    graph_data = graph.data("Match(n:Volunteer{name:'%s'})-[r]-(p) return n,r,p" % (login_name))
    nodesn_ = list(map(buildNodesn, graph_data))
    nodesn = []
    for node in nodesn_:
        if node not in nodesn:
            nodesn.append(node)
    nodesp = list(map(buildNodesp, graph_data))
    for node_list in nodesp:
        for node in node_list:
            if node not in nodesn:
                nodesn.append(node)  # 查询出的结果去重
    edges = []
    edger = list(map(buildEdgesn, graph_data))
    for edge_list in edger:
        for edge in edge_list:
            if edge not in edges:
                edges.append(edge)
    # nodesn_ = list(map(buildNodesn, graph.data("Match(n:Volunteer{name:'%s'})-[r]-(p) return n" % (login_name))))
    # nodesn = []
    # for node in nodesn_:
    #     if node not in nodesn:
    #         nodesn.append(node)
    # nodesp = list(map(buildNodesp, graph.data("Match(n:Volunteer{name:'%s'})-[r]-(p) return p" % (login_name))))
    # nodes = nodesn + nodesp
    # edges = list(map(buildEdgesn, graph.data("Match(n:Volunteer{name:'%s'})-[r]-(p) return r" %(login_name))))
    return nodesn, edges
def get_ques_graph_0(login_name, search_name):
    graph_data = graph.data("match r=shortestPath((n:Volunteer{name:'%s'})-[*]-"
                            "(p:Volunteer{name:'%s'})) return r" % (login_name, search_name))
    nodes = []
    edges = []
    for path in graph_data:
        nodes = list(map(buildNodes, path['r'].nodes()))
        edges = list(map(BuildEdges, path['r'].relationships()))
    return nodes, edges
def get_ques_graph_2(search_name):
    graph_data = graph.data("Match r=(:Volunteer{name:'%s'})-[]-(:Project) return r" % (search_name))
    nodes = []
    edges = []
    for path in graph_data:
        for node in list(map(buildNodes, path['r'].nodes())):
            if node not in nodes:
                nodes.append(node)
        for edge in list(map(BuildEdges, path['r'].relationships())):
            if edge not in edges:
                edges.append(edge)
    return nodes, edges
def get_all_graph(login_name):
    graph_data = graph.data("match (n1:Volunteer{name:'%s'})-[r1]-(p1)-[r2]-(n2:Volunteer)"
                            "-[r3]-(p2:Group)-[l1]-(p3:City)-[l2]-(p4:Province) "
                            "return n1,n2,p1,p2,p3,p4,l1,l2,r1,r2,r3" % (login_name))
    nodesn_ = list(map(buildNodesn, graph_data))
    nodesn = []
    for node in nodesn_:
        if node not in nodesn:
            nodesn.append(node)  # 查询出的结果去重
    nodesp = list(map(buildNodesp, graph_data))
    for node_list in nodesp:
        for node in node_list:
            if node not in nodesn:
                nodesn.append(node)  # 查询出的结果去重
    edger = list(map(buildEdgesn, graph_data))
    edgesr = []
    for edge_list in edger:
        for edge in edge_list:
            if edge not in edgesr:
                edgesr.append(edge)
    edger = list(map(buildEdges, graph_data))
    for edge_list in edger:
        for edge in edge_list:
            if edge not in edgesr:
                edgesr.append(edge)
    # nodesn_ = list(map(buildNodesn, graph.data("match (n:Volunteer{name:'%s'})-[*1..2]-(:Volunteer)"
    #                                            "-[]-(:Group)-[]-(:City)-[]-(:Province) return n" %(login_name))))
    # nodesn = []
    # for node in nodesn_:
    #     if node not in nodesn:
    #         nodesn.append(node)     # 查询出的结果去重
    # nodesn_ = list(map(buildNodesn, graph.data("match (:Volunteer{name:'%s'})-[*1..2]-(n:Volunteer)"
    #                                            "-[]-(:Group)-[]-(:City)-[]-(:Province) return n" %(login_name))))
    # for node in nodesn_:
    #     if node not in nodesn:
    #         nodesn.append(node)     # 查询出的结果去重
    # nodesn_ = list(map(buildNodesp, graph.data("match (:Volunteer{name:'%s'})-[*1..2]-(:Volunteer)"
    #                                            "-[]-(p:Group)-[]-(:City)-[]-(:Province) return p" % (login_name))))
    # for node in nodesn_:
    #     if node not in nodesn:
    #         nodesn.append(node)  # 查询出的结果去重
    # nodesn_ = list(map(buildNodesp, graph.data("match (:Volunteer{name:'%s'})-[]-(p) return p" % (login_name))))
    # for node in nodesn_:
    #     if node not in nodesn:
    #         nodesn.append(node)  # 查询出的结果去重
    # nodesn_ = list(map(buildNodesp, graph.data("match (:Volunteer{name:'%s'})-[*1..2]-(:Volunteer)"
    #                                            "-[]-(:Group)-[]-(p:City)-[]-(:Province) return p" % (login_name))))
    # for node in nodesn_:
    #     if node not in nodesn:
    #         nodesn.append(node)  # 查询出的结果去重
    # nodesn_ = list(map(buildNodesp, graph.data("match (:Volunteer{name:'%s'})-[*1..2]-(:Volunteer)"
    #                                            "-[]-(:Group)-[]-(:City)-[]-(p:Province) return p" % (login_name))))
    # for node in nodesn_:
    #     if node not in nodesn:
    #         nodesn.append(node)  # 查询出的结果去重
    # edger = list(map(buildEdgesn, graph.data("match (n:Volunteer{name:'%s'})-[r]-() return r" %(login_name))))
    # edgesr = []
    # for edge in edger:
    #     if edge not in edgesr:
    #         edgesr.append(edge)
    # edger = list(map(buildEdgesn, graph.data("match (:Volunteer{name:'%s'})-[]-()-[r]-(:Volunteer)"
    #                                          "-[]-(:Group)-[]-(:City)-[]-(:Province) return r" % (login_name))))
    # for edge in edger:
    #     if edge not in edgesr:
    #         edgesr.append(edge)
    # edger = list(map(buildEdgesn, graph.data("match (:Volunteer{name:'%s'})-[*1..2]-(:Volunteer)"
    #                                          "-[r]-(:Group)-[]-(:City)-[]-(:Province) return r" % (login_name))))
    # for edge in edger:
    #     if edge not in edgesr:
    #         edgesr.append(edge)
    # edger = list(map(buildEdges, graph.data("match (:Volunteer{name:'%s'})-[*1..2]-(:Volunteer)"
    #                                         "-[]-(:Group)-[r]-(:City)-[]-(:Province) return r" % (login_name))))
    # for edge in edger:
    #     if edge not in edgesr:
    #         edgesr.append(edge)
    # edger = list(map(buildEdges, graph.data("match (:Volunteer{name:'%s'})-[*1..2]-(:Volunteer)"
    #                                         "-[]-(:Group)-[]-(:City)-[r]-(:Province) return r" % (login_name))))
    # for edge in edger:
    #     if edge not in edgesr:
    #         edgesr.append(edge)
    # print(edgesr)
    return nodesn, edgesr