Directed graph with edges from knob residue to each hole residue for each KnobIntoHole in self.
497834
def daisy_chain_graph(self):
        
        g = networkx.DiGraph()
        for x in self.get_monomers():
            for h in x.hole:
                g.add_edge(x.knob, h)
        return g
1292522
def knob_subgroup(self, cutoff=7.0):
        
        if cutoff > self.cutoff:
            raise ValueError("cutoff supplied ({0}) cannot be greater than self.cutoff ({1})".format(cutoff,
                                                                                                     self.cutoff))
        return KnobGroup(monomers=[x for x in self.get_monomers()
                                   if x.max_kh_distance <= cutoff], ampal_parent=self.ampal_parent)
770849
def _generate_edges(self, edge_prob):
        
        self.E, self.parent = [], {}
        for i in range(self.m):
            if random() < edge_prob and i > 0:
                p_i = choice(i)
                self.E.append((p_i, i))
                self.parent[i] = p_i
795
function createEdgeIterator(graph, type) {
  if (graph.size === 0)
    return Iterator.empty();

  let iterator;

  if (type === 'mixed') {
    iterator = graph._edges.values();

    return new Iterator(function next() {
      const step = iterator.next();

      if (step.done)
        return step;

      const data = step.value;

      const value = [
        data.key,
        data.attributes,
        data.source.key,
        data.target.key,
        data.source.attributes,
        data.target.attributes
      ];

      return {value, done: false};
    });
  }

  iterator = graph._edges.values();

  return new Iterator(function next() {
    const step = iterator.next();

    if (step.done)
      return step;

    const data = step.value;

    if ((data instanceof UndirectedEdgeData) === (type === 'undirected')) {
      const value = [
        data.key,
        data.attributes,
        data.source.key,
        data.target.key,
        data.source.attributes,
        data.target.attributes
      ];

      return {value, done: false};
    }

    return next();
  });
}
609972
private Map<String, Integer> getHypotheses(Collection<KamEdge> edges) {
        Map<String, Integer> controlCountMap =
                getTranscriptionalControls(edges);
        Map<String, Integer> hypCountMap = new HashMap<String, Integer>();
        for (String hyp : controlCountMap.keySet()) {
            if (controlCountMap.get(hyp) >= 4) {
                hypCountMap.put(hyp, controlCountMap.get(hyp));
            }
        }
        return hypCountMap;
    }
61979
def chk_edges(self):
        """"""
        goids = set(self.go2obj)
        self.chk_edges_nodes(self.edges, goids, "is_a")
        for reltype, edges in self.edges_rel.items():
            self.chk_edges_nodes(edges, goids, reltype)
1280701
public static <V> Set<V> getIncomingVertices(DirectedGraph<V, DefaultEdge> graph, V target) {
        Set<DefaultEdge> edges = graph.incomingEdgesOf(target);
        Set<V> sources = new LinkedHashSet<V>();
        for (DefaultEdge edge : edges) {
            sources.add(graph.getEdgeSource(edge));
        }
        return sources;
    }
99222
def from_edges(edges):
        
        dag = DirectedGraph()
        for _u, _v in edges:
            dag.add_edge(_u, _v)
        return dag
1367078
def grid_edges(shape, inds=None, return_directions=True):
    
    if inds is None:
        inds = np.arange(np.prod(shape)).reshape(shape)
    # if not self.segparams['use_boundary_penalties'] and \
    #         boundary_penalties_fcn is None :
    if len(shape) == 2:
        edgx = np.c_[inds[:, :-1].ravel(), inds[:, 1:].ravel()]
        edgy = np.c_[inds[:-1, :].ravel(), inds[1:, :].ravel()]

        edges = [edgx, edgy]

        directions = [
            np.ones([edgx.shape[0]], dtype=np.int8) * 0,
            np.ones([edgy.shape[0]], dtype=np.int8) * 1,
        ]

    elif len(shape) == 3:
        # This is faster for some specific format
        edgx = np.c_[inds[:, :, :-1].ravel(), inds[:, :, 1:].ravel()]
        edgy = np.c_[inds[:, :-1, :].ravel(), inds[:, 1:, :].ravel()]
        edgz = np.c_[inds[:-1, :, :].ravel(), inds[1:, :, :].ravel()]
        edges = [edgx, edgy, edgz]
    else:
        logger.error("Expected 2D or 3D data")

    # for all edges along first direction put 0, for second direction put 1, for third direction put 3
    if return_directions:
        directions = []
        for idirection in range(len(shape)):
            directions.append(
                np.ones([edges[idirection].shape[0]], dtype=np.int8) * idirection
            )
    edges = np.concatenate(edges)
    if return_directions:
        edge_dir = np.concatenate(directions)
        return edges, edge_dir
    else:
        return edges
1301617
def to_graphviz(self) -> str:
        
        graph = "digraph finite_state_machine { rankdir=LR; node [fixedsize=true];"
        for origin, dest in self._transitions.items():
            origin = origin.replace(" ", "_")
            for d in dest:
                d = d.replace(" ", "_")
                graph += "{0} -> {1};".format(origin, d)
        graph += "}"
        return graph
558363
function createEdgeArray(graph, type) {
  if (graph.size === 0)
    return [];

  if (type === 'mixed' || type === graph.type)
    return take(graph._edges.keys(), graph._edges.size);

  const size = type === 'undirected' ?
    graph.undirectedSize :
    graph.directedSize;

  const list = new Array(size),
        mask = type === 'undirected';

  let i = 0;

  graph._edges.forEach((data, edge) => {

    if ((data instanceof UndirectedEdgeData) === mask)
      list[i++] = edge;
  });

  return list;
}
378993
def digraph_walker_backwards(graph, element, call_back):
    """"""
    call_back(graph, element)
    for predecessor in graph.predecessors(element):
        call_back(graph, predecessor)
    for predecessor in graph.predecessors(element):
        digraph_walker_backwards(graph, predecessor, call_back)
256839
def to_dot_graph (params = {})
      params['name'] ||= self.class.name.gsub(/:/,'_')
      fontsize   = params['fontsize'] || '8'
      fontname   = params['fontname'] || 'Times-Roman'
      graph      = (directed? ? DOT::Digraph : DOT::Subgraph).new(params)
      edge_class = directed? ? DOT::DirectedEdge : DOT::Edge
      shape = params['shape'] || 'ellipse'
      each_vertex do |v|
        name = v.to_s
        graph << DOT::Node.new('name'     => name,
                               'fontsize' => fontsize,
                               'label'    => name,
                               'shape'    => shape,
                               'fontname' => fontname)
      end
      each_edge do |u,v|
        if respond_to?(:is_abnormal?)
          if is_abnormal?(u, v) && is_block_taken?(u, v)
            color = 'blue'
          elsif is_abnormal?(u, v)
            color = 'red'
          elsif is_fake?(u, v)
            color = '#bbbbbb'
          else
            color = 'black'
          end
          style = (is_fake?(u, v) || !is_executable?(u, v)) ? 'dashed' : 'solid'
        else
          color = 'black'
          style = 'solid'
        end
        graph << edge_class.new('from'     => u.to_s,
                                'to'       => v.to_s,
                                'fontsize' => fontsize,
                                'fontname' => fontname,
                                'color'    => color,
                                'style'    => style)
      end
      graph
    end
684930
def neighbors(self, key):
        """"""
        return {n: attr["bond"] for n, attr in self.graph[key].items()}
398726
private Set<Integer> getSuccessors(Graph g, Integer vertex) {
        if (g instanceof DirectedGraph) {
            DirectedGraph<?> dg = (DirectedGraph)g;
            return dg.successors(vertex);
        }
        else
            return Collections.<Integer>emptySet();
    }
985756
public Graph<Attribute>[] createIDS(Graph<AttributeOccurrence>[] idp) {
        int p;
        int i;
        Graph<Attribute>[] ids;
        AttributeOccurrence left;
        AttributeOccurrence right;
        EdgeIterator<AttributeOccurrence> iter;

        ids = new Graph[symbols.last() + 1];
        for (i = 0; i < ids.length; i++) {
            ids[i] = new Graph<Attribute>();
        }
        for (p = 0; p < idp.length; p++) {
            iter = idp[p].edges();
            while (iter.step()) {
                left = iter.left();
                right = iter.right();
                if (left.sameSymbolOccurrence(right)) {
                    ids[left.attr.symbol].addEdge(left.attr, right.attr);
                }
            }
        }
        return ids;
    }
180062
def makediagram(edges):
    """"""
    graph = pydot.Dot(graph_type='digraph')
    nodes = edges2nodes(edges)
    epnodes = [(node, 
        makeanode(node[0])) for node in nodes if nodetype(node)=="epnode"]
    endnodes = [(node, 
        makeendnode(node[0])) for node in nodes if nodetype(node)=="EndNode"]
    epbr = [(node, makeabranch(node)) for node in nodes if not istuple(node)]
    nodedict = dict(epnodes + epbr + endnodes)
    for value in list(nodedict.values()):
        graph.add_node(value)
    for e1, e2 in edges:
        graph.add_edge(pydot.Edge(nodedict[e1], nodedict[e2]))
    return graph