(G, gdf_network, fields, multigraph)
Generate primal graph.
    Helper for gdf_to_nx.
Generate primal graph.
    Helper for gdf_to_nx.
Generate primal graph . Helper for gdf_to_nx .
def _generate_primal(G, gdf_network, fields, multigraph):
    """
    Generate primal graph.
    Helper for gdf_to_nx.
    """
    G.graph["approach"] = "primal"
    key = 0
    for row in gdf_network.itertuples():
        first = row.geometry.coords[0]
        last = row.geometry.coords[-1]

        data = [r for r in row][1:]
        attributes = dict(zip(fields, data))
        if multigraph:
            G.add_edge(first, last, key=key, **attributes)
            key += 1
        else:
            G.add_edge(first, last, **attributes)
def _generate_primal ( G , gdf_network , fields , multigraph ) : G . graph [ "approach" ] = "primal" key = 0 for row in gdf_network . itertuples ( ) : first = row . geometry . coords [ 0 ] last = row . geometry . coords [ - 1 ] data = [ r for r in row ] [ 1 : ] attributes = dict ( zip ( fields , data ) ) if multigraph : G . add_edge ( first , last , key = key , * * attributes ) key += 1 else : G . add_edge ( first , last , * * attributes )