[Python] How check if there is intersection of any two edges given the fixed nodes positions,...

Discussão em 'Python' iniciado por Stack, Fevereiro 15, 2025.

  1. Stack

    Stack Membro Participativo

    What I want?

    I want to check if there is any interscions beteewn edges in my graph. I have a graph with a lot of vertices and edges.

    Here is a simple graph for example:

    G = nx.Graph().to_undirected()
    G.add_nodes_from(pos)
    G.add_edge(1, 3, weight=1)
    G.add_edge(2, 4, weight=1)
    G.add_edge(2, 3, weight=1)
    nx.draw_networkx(G, with_labels=True, pos=pos)
    plt.show()


    [​IMG]

    What I have tried?

    I already tried to use

    print(nx.check_planarity(G, False))


    but because there is an option to draw this graph as a planar graph, the return value is True

    How can I check if there are edge interscions in my graph? assuming the position is fixed and the edges are drawn as straight lines

    Continue reading...

Compartilhe esta Página