from typing import List
import networkx


def parse_input(puzzle_input: List[str]) -> networkx.DiGraph:
    """Parse the puzzle input for part 1 by making a graph of what is contained by what"""
    graph = networkx.DiGraph()
    nodes = []
    for line in puzzle_input:
        source, targets = line[:-1].split(" bags contain ")
        for target in targets.split(", "):
            if target == "no other bags":
                # we've found an edge node
                continue
            # count = int(target.split()[0])
            color = " ".join(target.split()[1:-1])
            nodes.append((color, source))
    graph.add_edges_from(nodes)
    return graph