def adjacency_matrix(edges):
    """
    Convert a directed graph to an adjacency matrix.

    Note: The distance from a node to itself is 0 and distance from a node to
    an unconnected node is defined to be infinite.

    Parameters
    ----------
    edges : list of tuples
            list of dependencies between nodes in the graph
            [(source node, destination node, weight), ...]

    Returns
    -------
    out : tuple
          (names, adjacency matrix)
          names - list of unique nodes in the graph
          adjacency matrix represented as list of lists

    """
    # determine the set of unique nodes
    names = set()
    for src, dest, _ in edges:
        # add source and destination nodes
        names.add(src)
        names.add(dest)
    # convert set of names to sorted list
    names = sorted(names)
    # determine initial adjacency matrix with infinity weights
    matrix = [[float('Inf')] * len(names) for _ in names]
    for src, dest, weight in edges:
        # update weight in adjacency matrix
        matrix[names.index(src)][names.index(dest)] = weight

    for src in names:
        matrix[names.index(src)][names.index(src)] = 0
    # return list of names and adjacency matrix
    return names, matrix