How to use the hypernetx.drawing.util.get_set_layering function in hypernetx

To help you get started, we’ve selected a few hypernetx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pnnl / HyperNetX / hypernetx / drawing / rubber_band.py View on Github external
matplotlib axis on which the plot is rendered

    Returns
    -------
    dict
        A mapping from hyper edge ids to paths (Nx2 numpy matrices)
    '''

    if len(node_radius):
        r0 = min(node_radius.values())
    else:
        r0 = get_default_radius(H, pos)

    dr = dr or r0
    
    levels = get_set_layering(H)

    radii = {v: {v: i for i, v in enumerate(sorted(e, key=levels.get))}
             for v, e in H.dual().edges.elements.items()}

    def get_padded_hull(edge):
        # make sure the edge contains at least one node
        if len(edge):
            points = np.vstack([cp*(node_radius.get(v, r0) + dr*(2 + radii[v][edge.uid])) + pos[v]
                                for v in edge])
        # if not, draw an empty edge centered aroudn the location of the edge node (in the bipartite graph)
        else:
            points = 4*r0*cp + pos[edge.uid]
        
        hull = ConvexHull(points)
        
        return hull.points[hull.vertices]