Skip to content

Wrong connected vertices in a non-triangulated mesh #1067

Answered by sergei9838
sergei9838 asked this question in Q&A
Discussion options

You must be logged in to vote

If this is for some use to the community, here is my solution:

def adjacency_list(msh: Mesh) -> list:
    """
    Computes the adjacency list for mesh `msh` edge-graph
    :param msh: a mesh
    :return: a list with i-th entry being the set if indices of vertices connected by an edge to i-th vertex
    """
    inc = [set()] * msh.nvertices
    for cell in msh.cells:
        if len(cell) > 1:
            for i in range(len(cell)-1):
                inc[cell[i]] = inc[cell[i]].union({cell[i-1], cell[i+1]})
    return inc


def graph_ball(index, n: int, msh: Mesh) -> set:
    """
    Computes the ball of radius `n` in the mesh' edge-graph metric centred in vertex `index`
    :param index: in…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@sergei9838
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by sergei9838
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants