import shlex


def parse_nodes(line, graph):
    """
    Add DOT nodes to the graphit Graph

    :param line:  line with nodes to parse
    :type line:   :py:str
    :param graph: Graph to add nodes to
    :type graph:  :graphit:Graph

    :return:      added nodes
    :rtype:       :py:list
    """

    nodes = [l.strip(',') for l in shlex.split(line)]

    for node in nodes:
        if node not in graph.nodes:
            graph.add_node(node)

    return nodes