(AggOp, V, E, G,
             ax, color='b', edgecolor='0.5', lw=1)
Parameters
    ----------
    AggOp : CSR sparse matrix
        n x nagg encoding of the aggregates AggOp[i,j] == 1 means node i is in aggregate j
    V : ndarray
        n x 2 coordinate array of the mesh
    E : ndarray
        nel x 3 index array of the mesh elements
    G : CSR sparse matrix
        n x n connectivity matrix for the vertices
    ax : axis
        matplotlib axis
    color : string
        color of the aggregates
    edgecolor : string
        color of the aggregate edges
    lw : float
        line width of the aggregate edges
Parameters
    ----------
    AggOp : CSR sparse matrix
        n x nagg encoding of the aggregates AggOp[i,j] == 1 means node i is in aggregate j
    V : ndarray
        n x 2 coordinate array of the mesh
    E : ndarray
        nel x 3 index array of the mesh elements
    G : CSR sparse matrix
        n x n connectivity matrix for the vertices
    ax : axis
        matplotlib axis
    color : string
        color of the aggregates
    edgecolor : string
        color of the aggregate edges
    lw : float
        line width of the aggregate edges
Parameters ---------- AggOp : CSR sparse matrix n x nagg encoding of the aggregates AggOp [ i j ] == 1 means node i is in aggregate j V : ndarray n x 2 coordinate array of the mesh E : ndarray nel x 3 index array of the mesh elements G : CSR sparse matrix n x n connectivity matrix for the vertices ax : axis matplotlib axis color : string color of the aggregates edgecolor : string color of the aggregate edges lw : float line width of the aggregate edges
def plotaggs(AggOp, V, E, G,
             ax, color='b', edgecolor='0.5', lw=1):
    """
    Parameters
    ----------
    AggOp : CSR sparse matrix
        n x nagg encoding of the aggregates AggOp[i,j] == 1 means node i is in aggregate j
    V : ndarray
        n x 2 coordinate array of the mesh
    E : ndarray
        nel x 3 index array of the mesh elements
    G : CSR sparse matrix
        n x n connectivity matrix for the vertices
    ax : axis
        matplotlib axis
    color : string
        color of the aggregates
    edgecolor : string
        color of the aggregate edges
    lw : float
        line width of the aggregate edges
    """

    for aggnum, agg in enumerate(AggOp.T):                                    # for each aggregate
        aggids = agg.indices                               # get the indices

        todraw = []                                        # collect things to draw
        if len(aggids) == 1:
            i = aggids[0]
            coords = (V[i, 0], V[i,1])
            newobj = sg.Point(coords)
            todraw.append(newobj)

        for i in aggids:                                   # for each point in the aggregate
            nbrs = G.getrow(i).indices                     # get the neighbors in the graph

            for j1 in nbrs:                                # for each neighbor
                found = False                              # mark if a triad ("triangle") is found
                for j2 in nbrs:
                    if (j1!=j2 and i!=j1 and i!=j2 and     # don't count i - j - j as a triangle
                        j1 in aggids and j2 in aggids and  # j1/j2 are in the aggregate
                        G[j1,j2]                           # j1/j2 are connected
                       ):
                        found = True                       # i - j1 - j2 are in the aggregate
                        coords = list(zip(V[[i,j1,j2], 0], V[[i,j1,j2],1]))
                        todraw.append(sg.Polygon(coords))  # add the triangle to the list
                if not found and i!=j1 and j1 in aggids:   # if we didn't find a triangle, then ...
                    coords = list(zip(V[[i,j1], 0], V[[i,j1],1]))
                    newobj = sg.LineString(coords)         # add a line object to the list
                    todraw.append(newobj)

        todraw = cascaded_union(todraw)                    # union all objects in the aggregate
        todraw = todraw.buffer(0.1)                        # expand to smooth
        todraw = todraw.buffer(-0.05)                      # then contract

        try:
            xs, ys = todraw.exterior.xy                    # get all of the exterior points
            ax.fill(xs, ys, color=color,
                    clip_on=False)                         # fill with a color
        except:
            print('uh oh')
            pass                                           # when does this happen

    # aggregate edges
    Edges = np.vstack((A.tocoo().row,A.tocoo().col)).T  # edges of the matrix graph
    inner_edges = AggOp.indices[Edges[:,0]] == AggOp.indices[Edges[:,1]]
    aggs = V[Edges[inner_edges].ravel(),:].reshape((-1, 2, 2))
    col = mplt.collections.LineCollection(aggs,
                                          color=edgecolor,
                                          linewidth=lw)
    ax.add_collection(col, autolim=True)

    ax.set_aspect('equal')
def plotaggs ( AggOp , V , E , G , ax , color = 'b' , edgecolor = '0.5' , lw = 1 ) : for aggnum , agg in enumerate ( AggOp . T ) : # for each aggregate aggids = agg . indices # get the indices todraw = [ ] # collect things to draw if len ( aggids ) == 1 : i = aggids [ 0 ] coords = ( V [ i , 0 ] , V [ i , 1 ] ) newobj = sg . Point ( coords ) todraw . append ( newobj ) for i in aggids : # for each point in the aggregate nbrs = G . getrow ( i ) . indices # get the neighbors in the graph for j1 in nbrs : # for each neighbor found = False # mark if a triad ("triangle") is found for j2 in nbrs : if ( j1 != j2 and i != j1 and i != j2 and # don't count i - j - j as a triangle j1 in aggids and j2 in aggids and # j1/j2 are in the aggregate G [ j1 , j2 ] # j1/j2 are connected ) : found = True # i - j1 - j2 are in the aggregate coords = list ( zip ( V [ [ i , j1 , j2 ] , 0 ] , V [ [ i , j1 , j2 ] , 1 ] ) ) todraw . append ( sg . Polygon ( coords ) ) # add the triangle to the list if not found and i != j1 and j1 in aggids : # if we didn't find a triangle, then ... coords = list ( zip ( V [ [ i , j1 ] , 0 ] , V [ [ i , j1 ] , 1 ] ) ) newobj = sg . LineString ( coords ) # add a line object to the list todraw . append ( newobj ) todraw = cascaded_union ( todraw ) # union all objects in the aggregate todraw = todraw . buffer ( 0.1 ) # expand to smooth todraw = todraw . buffer ( - 0.05 ) # then contract try : xs , ys = todraw . exterior . xy # get all of the exterior points ax . fill ( xs , ys , color = color , clip_on = False ) # fill with a color except : print ( 'uh oh' ) pass # when does this happen # aggregate edges Edges = np . vstack ( ( A . tocoo ( ) . row , A . tocoo ( ) . col ) ) . T # edges of the matrix graph inner_edges = AggOp . indices [ Edges [ : , 0 ] ] == AggOp . indices [ Edges [ : , 1 ] ] aggs = V [ Edges [ inner_edges ] . ravel ( ) , : ] . reshape ( ( - 1 , 2 , 2 ) ) col = mplt . collections . LineCollection ( aggs , color = edgecolor , linewidth = lw ) ax . add_collection ( col , autolim = True ) ax . set_aspect ( 'equal' )