Create the computational graph's placeholders.
176363
def _create_placeholders(self):
        """"""
        self.input_data = tf.placeholder(
            tf.int32, [self.batch_size, self.num_steps])
        self.input_labels = tf.placeholder(
            tf.int32, [self.batch_size, self.num_steps])
1093297
def iter_cloneable_placeholders(self):
        
        latent_ph_types = (
            PP_PLACEHOLDER.DATE, PP_PLACEHOLDER.FOOTER,
            PP_PLACEHOLDER.SLIDE_NUMBER
        )
        for ph in self.placeholders:
            if ph.element.ph_type not in latent_ph_types:
                yield ph
415304
def build_graph(formula):
    '''  '''
    graph = {}

    for clause in formula:
        for (lit, _) in clause:
            for neg in [False, True]:
                graph[(lit, neg)] = []

    for ((a_lit, a_neg), (b_lit, b_neg)) in formula:
        add_edge(graph, (a_lit, a_neg), (b_lit, not b_neg))
        add_edge(graph, (b_lit, b_neg), (a_lit, not a_neg))

    return graph
1043388
def generate(self):
        
        t = (self.context.identifier, RDF.type, META.Provenance)
        if t not in self.context.graph:
            self.context.graph.add(t)
        for name, value in self.data.items():
            pat = (self.context.identifier, META[name], None)
            if pat in self.context.graph:
                self.context.graph.remove(pat)
            self.context.graph.add((pat[0], META[name], Literal(value)))
345052
def _bsecurate_cli_make_graph_file(args):
    ''''''

    curate.make_graph_file(args.basis, args.outfile, args.render, args.version, args.data_dir)
    return ''
434926
function createGraphvizOptions(config) {
	const graphVizOptions = config.graphVizOptions || {};

	return {
		G: Object.assign({
			overlap: false,
			pad: 0.3,
			rankdir: config.rankdir,
			layout: config.layout,
			bgcolor: config.backgroundColor
		}, graphVizOptions.G),
		E: Object.assign({
			color: config.edgeColor
		}, graphVizOptions.E),
		N: Object.assign({
			fontname: config.fontName,
			fontsize: config.fontSize,
			color: config.nodeColor,
			shape: config.nodeShape,
			style: config.nodeStyle,
			height: 0,
			fontcolor: config.nodeColor
		}, graphVizOptions.N)
	};
}
484904
def build_patterns(fnames):
    """"""
    patterns = []
    for fn in fnames:
        et = ET.parse(fn)
        res = et.findall('CC') + et.findall('EVENT')
        for event in res:
            G = networkx.DiGraph()
            build_event_graph(G, et, event)
            add_graph(patterns, G)
    patterns = sorted(patterns, key=lambda x: len(x[0]), reverse=True)
    return patterns
81512
def as_graph(self) -> Graph:  # pragma: no cover
        """"""
        if Graph is None:
            raise ImportError('The graphviz package is required to draw the graph.')
        graph = Graph()
        nodes_left = {}  # type: Dict[TLeft, str]
        nodes_right = {}  # type: Dict[TRight, str]
        node_id = 0
        for (left, right), value in self._edges.items():
            if left not in nodes_left:
                name = 'node{:d}'.format(node_id)
                nodes_left[left] = name
                graph.node(name, label=str(left))
                node_id += 1
            if right not in nodes_right:
                name = 'node{:d}'.format(node_id)
                nodes_right[right] = name
                graph.node(name, label=str(right))
                node_id += 1
            edge_label = value is not True and str(value) or ''
            graph.edge(nodes_left[left], nodes_right[right], edge_label)
        return graph
788085
def _make_nodes(self, dsk_graph, array, iteration_order, masked,
                    top=False):
        
        cache_key = _array_id(array, iteration_order, masked)
        # By the end of this function Nodes will be a dictionary with one item
        # per chunk to be processed for this array.
        nodes = self._node_cache.get(cache_key, None)

        if nodes is None:
            if hasattr(array, 'streams_handler'):
                nodes = self._make_stream_handler_nodes(dsk_graph, array,
                                                        iteration_order,
                                                        masked)
            else:
                nodes = {}
                chunks = []

                name = '{}\n{}'.format(array.__class__.__name__, array.shape)
                biggus_chunk_func = self.lazy_chunk_creator(name)

                chunk_index_gen = biggus._init.ProducerNode.chunk_index_gen
                for chunk_key in chunk_index_gen(array.shape,
                                                 iteration_order[::-1]):
                    biggus_array = array[chunk_key]
                    pretty_key = ', '.join(map(slice_repr, chunk_key))
                    chunk_id = ('chunk shape: {}\nsource key: [{}]\n\n{}'
                                ''.format(biggus_array.shape, pretty_key,
                                          uuid.uuid4()))
                    task = (biggus_chunk_func, chunk_key, biggus_array, masked)
                    chunks.append(task)
                    assert chunk_id not in dsk_graph
                    dsk_graph[chunk_id] = task
                    nodes[chunk_id] = task
            self._node_cache[cache_key] = nodes
        return nodes
665912
def from_dict(self, graph_dict):
        

        self.reset_graph()
        for new_node in six.iterkeys(graph_dict):
            self.add_node(new_node)
        for ind_node, dep_nodes in six.iteritems(graph_dict):
            if not isinstance(dep_nodes, list):
                raise TypeError('dict values must be lists')
            for dep_node in dep_nodes:
                self.add_edge(ind_node, dep_node)
125595
def _construct(self):
        

        self._acyclic_cfg = self._cfg.copy()
        # TODO: Cycle-removing is not needed - confirm it later
        # The CFG we use should be acyclic!
        #self._acyclic_cfg.remove_cycles()

        # Pre-process the acyclic CFG
        self._pre_process_cfg()

        # Construct post-dominator tree
        self._pd_construct()

        self._graph = networkx.DiGraph()

        # Construct the reversed dominance frontier mapping
        rdf = compute_dominance_frontier(self._normalized_cfg, self._post_dom)

        for y in self._cfg.graph.nodes():
            if y not in rdf:
                continue
            for x in rdf[y]:
                self._graph.add_edge(x, y)
1019817
def create_copy_without_data(G):
    """"""
    H = nx.Graph()
    for i in H.nodes_iter():
        H.node[i] = {}
    return H
163003
def create_graph(grid):
    
    try:
        import numpy as np
    except ImportError:
        print(
            "NumPY is not installed. segraph needs NumPY to function. Please use 'pip install numpy' to install numpy.")
        exit(0)
    print("Creating a graph using segmented grid..")
    # get an array of unique labels
    try:
        vertices = np.unique(grid)

        # get number of vertices
        num_vertices = len(vertices)

        # map these unique labels to [1,...,N], where N is the number of labels (vertices)
        mapping = dict(zip(vertices, np.arange(num_vertices)))
        mapped_grid = np.array([mapping[x] for x in grid.flat]).reshape(grid.shape)

        # create edges, going left to right and top to bottom
        l2r = np.c_[mapped_grid[:, :-1].ravel(), mapped_grid[:, 1:].ravel()]
        t2b = np.c_[mapped_grid[:-1, :].ravel(), mapped_grid[1:, :].ravel()]

        # stack for entire graph
        edges = np.vstack([l2r, t2b])
        edges = edges[edges[:, 0] != edges[:, 1], :]
        edges = np.sort(edges, axis=1)

        # create a edge map, a hashmap
        edge_map = edges[:, 0] + num_vertices * edges[:, 1]

        # filter unique connections as edges
        edges = np.unique(edge_map)

        # reverse map and form edges as pairs
        edges = [[vertices[edge % num_vertices],
                  vertices[edge // num_vertices]] for edge in edges]
    except:
        print("Invalid argument supplied !")
        return None

    return vertices, edges
354053
def build_model(self):
        """"""
        with tf.variable_scope(
                "model", reuse=None, initializer=self.initializer):
            self._create_placeholders()
            self._create_rnn_cells()
            self._create_initstate_and_embeddings()
            self._create_rnn_architecture()
            self._create_optimizer_node()
145444
def build_cycle_graph(num_nodes):
    """"""
    graph = UndirectedGraph()

    if num_nodes > 0:
        first_node = graph.new_node()
        if num_nodes > 1:
            previous_node = first_node
            for _ in range(num_nodes - 1):
                new_node = graph.new_node()
                graph.new_edge(previous_node, new_node)
                previous_node = new_node
            graph.new_edge(previous_node, first_node)

    return graph
994365
function graph(g) {
    init(g);

    var xs = [upperLeft(g), upperRight(g), lowerRight(g), lowerLeft(g)];

    g.nodes().forEach(function(u) {
      var xArray = [];
      for (var i = 0; i < xs.length; ++i) {
        xArray.push(xs[i][u]);
      }
      xArray.sort();
      g.node(u).x = (xArray[1] + xArray[2]) / 2;
    });
  }
671118
def polygon_generator(data, scale, style, permutation=None):
    """"""

    # We'll project the coordinates inside this function to prevent
    # passing around permutation more than necessary
    project = functools.partial(project_point, permutation=permutation)

    if isinstance(data, dict):
        data_gen = data.items()
    else:
        # Only works with style == 'h'
        data_gen = data

    for key, value in data_gen:
        if value is None:
            continue
        i = key[0]
        j = key[1]
        k = scale - i - j
        if style == 'h':
            vertices = hexagon_coordinates(i, j, k)
            yield (map(project, vertices), value)
        elif style == 'd':
            # Upright triangles
            if (i <= scale) and (j <= scale) and (k >= 0):
                vertices = triangle_coordinates(i, j, k)
                yield (map(project, vertices), value)
            # Upside-down triangles
            if (i < scale) and (j < scale) and (k >= 1):
                vertices = alt_triangle_coordinates(i, j, k)
                value = blend_value(data, i, j, k)
                yield (map(project, vertices), value)
        elif style == 't':
            # Upright triangles
            if (i < scale) and (j < scale) and (k > 0):
                vertices = triangle_coordinates(i, j, k)
                value = blend_value(data, i, j, k)
                yield (map(project, vertices), value)
            # If not on the boundary add the upside-down triangle
            if (i < scale) and (j < scale) and (k > 1):
                vertices = alt_triangle_coordinates(i, j, k)
                value = alt_blend_value(data, i, j, k)
                yield (map(project, vertices), value)