Returns an open conjunctive graph.
19716
def get_conjunctive_graph(store_id=None):
    
    if not store_id:
        store_id = DEFAULT_STORE

    store = DjangoStore(DEFAULT_STORE)
    graph = ConjunctiveGraph(store=store, identifier=store_id)
    if graph.open(None) != VALID_STORE:
        raise ValueError("The store identified by {0} is not a valid store".format(store_id))
    return graph
707088
def _make_graph(self, max_insert):
        ''''''
        if len(self.partial_links) != 0:
            raise Error('Error in _make_graph(). Cannot continue because there are partial links')
        
        self.contig_links = {}
        for key in self.links:
            for l in self.links[key]:
                insert_size = l.insert_size()
                if insert_size <= max_insert:
                    if key not in self.contig_links:
                        self.contig_links[key] = {}
                    dirs = ''.join(l.dirs)
                    self.contig_links[key][dirs] = self.contig_links[key].get(dirs, 0) + 1
851326
function(graph, opt) {

        opt = opt || {};

        var glGraphType = _.pick(opt, 'directed', 'compound', 'multigraph');
        var glGraph = new graphlib.Graph(glGraphType);
        var setNodeLabel = opt.setNodeLabel || _.noop;
        var setEdgeLabel = opt.setEdgeLabel || _.noop;
        var setEdgeName = opt.setEdgeName || _.noop;

        graph.get('cells').each(function(cell) {

            if (cell.isLink()) {

                var source = cell.get('source');
                var target = cell.get('target');

                // Links that end at a point are ignored.
                if (!source.id || !target.id) return;

                // Note that if we are creating a multigraph we can name the edges. If
                // we try to name edges on a non-multigraph an exception is thrown.
                glGraph.setEdge(source.id, target.id, setEdgeLabel(cell), setEdgeName(cell));

            } else {

                glGraph.setNode(cell.id, setNodeLabel(cell));

                // For the compound graphs we have to take embeds into account.
                if (glGraph.isCompound() && cell.has('parent')) {
                    glGraph.setParent(cell.id, cell.get('parent'));
                }
            }
        });

        return glGraph;
    }
104474
def build_chvatal_graph():
    """"""
    # The easiest way to build the Chvatal graph is to start
    # with C12 and add the additional 12 edges
    graph = build_cycle_graph(12)

    edge_tpls = [
        (1,7), (1,9), (2,5), (2,11),
        (3,7), (3,9), (4,10), (4,12),
        (5,8), (6,10), (6,12), (8,11),
    ]

    for i, j in edge_tpls:
        graph.new_edge(i, j)

    return graph
229407
def connected_subgraphs(self, directed=True, ordered=False):
    '''
    '''
    num_ccs, labels = self.connected_components(directed=directed)
    # check the trivial case first
    if num_ccs == 1:
      yield self
      raise StopIteration
    if ordered:
      # sort by descending size (num vertices)
      order = np.argsort(np.bincount(labels))[::-1]
    else:
      order = range(num_ccs)

    # don't use self.subgraph() here, because we can reuse adj
    adj = self.matrix('dense', 'csr', 'csc')
    for c in order:
      mask = labels == c
      sub_adj = adj[mask][:,mask]
      yield self.__class__.from_adj_matrix(sub_adj)
843970
def predicates(graph):
    
    seen = set()

    def _traverse(binding):
        if binding.path in seen:
            return
        seen.add(binding.path)

        if binding.is_object:
            for prop in binding.properties:
                yield (binding.path, prop.name, tuple(prop.types))
                for pred in _traverse(prop):
                    yield pred
        elif binding.is_array:
            for item in binding.items:
                for pred in _traverse(item):
                    yield pred

    schemas = graph.aliases.values()
    schemas.extend(graph.resolver.store)
    for schema_uri in graph.aliases.values():
        binding = graph.get_binding(schema_uri, None)
        for pred in _traverse(binding):
            if pred not in seen:
                yield pred
                seen.add(pred)
978969
def open(self):
        """"""
        if self._state != 'open':
            if self._line is not None:
                self._state = 'open'
                self._nodes = self.grid.graph.nodes_from_line(self._line)
                self.grid.graph.remove_edge(
                    self._nodes[0], self._nodes[1])
            else:
                raise ValueError('``line`` is not set')
538070
def bind_graph(graph=None):
    
    if graph is None:
        graph = Graph()
    for prefix, ns in GRAPH_BINDINGS.items():
        graph.bind(prefix, ns, True)
    return graph
1364226
def rdf2dot( g, stream, opts={} ):
    

    accept_lang = set( opts.get('lang',[]) )
    do_literal = opts.get('literal')
    nodes = {}
    links = []

    def node_id(x):
        if x not in nodes:
            nodes[x] = "node%d" % len(nodes)
        return nodes[x]

    def qname(x, g):
        try:
            q = g.compute_qname(x)
            return q[0] + ":" + q[2]
        except:
            return x

    def accept( node ):
        if isinstance( node, (rdflib.URIRef,rdflib.BNode) ):
            return True
        if not do_literal:
            return False
        return (not accept_lang) or (node.language in accept_lang)


    stream.write( u'digraph { \n node [ fontname="DejaVu Sans,Tahoma,Geneva,sans-serif" ] ; \n' )

    # Write all edges. In the process make a list of all nodes
    for s, p, o in g:
        # skip triples for labels
        if p == rdflib.RDFS.label:
            continue

        # Create a link if both objects are graph nodes
        # (or, if literals are also included, if their languages match)
        if not (accept(s) and accept(o)):
            continue

        # add the nodes to the list
        sn = node_id(s)
        on = node_id(o)

        # add the link
        q = qname(p,g)
        if isinstance(p, rdflib.URIRef):
            opstr = u'\t%s -> %s [ arrowhead="open", color="#9FC9E560", fontsize=9, fontcolor="#204080", label="%s", href="%s", target="_other" ] ;\n' % (sn,on,q,p)
        else:
            opstr = u'\t%s -> %s [ arrowhead="open", color="#9FC9E560", fontsize=9, fontcolor="#204080", label="%s" ] ;\n'%(sn,on,q)
        stream.write( opstr )

    # Write all nodes
    for u, n in nodes.items():
        lbl = escape( label(u,g,accept_lang), True )
        if isinstance(u, rdflib.URIRef):
            opstr = u'%s [ shape=none, fontsize=10, fontcolor=%s, label="%s", href="%s", target=_other ] \n' % (n, 'blue', lbl, u )
        else:
            opstr = u'%s [ shape=none, fontsize=10, fontcolor=%s, label="%s" ] \n' % (n, 'black', lbl )
        stream.write( u"# %s %s\n" % (u, n) )
        stream.write( opstr )

    stream.write(u'}\n')
149399
def open(self):
        
        self.branch_nodes = self.grid.graph_nodes_from_branch(self.branch)
        self.grid._graph.remove_edge(self.branch_nodes[0], self.branch_nodes[1])
        self.status = 'open'
657441
def as_graph(self, depth=0):
        
        if depth in self._graph_cache:
            return self._graph_cache[depth]
        self._graph_cache[depth] = graph = Graph(self, depth=depth)
        return graph
322189
function graphFromStatements (rdf, statements) {
  let graph = rdf.graph()

  statements.forEach((st) => { graph.addStatement(st) })

  return graph
}
124610
def get_graph(graph=None, *, _limit=(), _print=()):
    
    graph = graph or bonobo.Graph()

    producer = (
        graph.get_cursor()
        >> ODSReader(dataset="liste-des-cafes-a-un-euro", netloc="opendata.paris.fr")
        >> PartialGraph(*_limit)
        >> bonobo.UnpackItems(0)
        >> bonobo.Rename(name="nom_du_cafe", address="adresse", zipcode="arrondissement")
        >> bonobo.Format(city="Paris", country="France")
        >> bonobo.OrderFields(["name", "address", "zipcode", "city", "country", "geometry", "geoloc"])
        >> PartialGraph(*_print)
    )

    # Comma separated values.
    graph.get_cursor(producer.output) >> bonobo.CsvWriter(
        "coffeeshops.csv", fields=["name", "address", "zipcode", "city"], delimiter=","
    )

    # Standard JSON
    graph.get_cursor(producer.output) >> bonobo.JsonWriter(path="coffeeshops.json")

    # Line-delimited JSON
    graph.get_cursor(producer.output) >> bonobo.LdjsonWriter(path="coffeeshops.ldjson")

    return graph
563238
public GraphObject getGraphObject(Object obj)
	{
		String key = getKey(obj);
		GraphObject go = objectMap.get(key);

//		if (obj instanceof Conversion && go == null)
//		{
//			go = objectMap.get(key + ConversionWrapper.LEFT_TO_RIGHT);
//			if (go == null)
//				go = objectMap.get(key + ConversionWrapper.RIGHT_TO_LEFT);
//		}

		if (go == null)
		{
			Node node = wrap(obj);

			if (node != null)
			{
				objectMap.put(key, node);
				node.init();
			}
		}

		return objectMap.get(key);
	}
911397
private function getOpenGraph(): array {
        $results = array();

        $nodes = $this->article()->getDoc()->find('meta[property^="og:"]');

        foreach ($nodes as $node) {
            $property = explode(':', $node->attr('property'));
            array_shift($property);
            $results[implode(':', $property)] = $node->attr('content');
        }

        // Additionally retrieve type values based on provided og:type (http://ogp.me/#types)
        if (isset($results['type'])) {
            $nodes = $this->article()->getDoc()->find('meta[property^="' . $results['type'] .':"]');

            foreach ($nodes as $node) {
                $property = explode(':', $node->attr('property'));
                array_shift($property);
                $results[implode(':', $property)] = $node->attr('content');
            }
        }

        return $results;
    }
1104435
def get_pydot_graph(self):
        """"""
        rel = "is_a"
        # Initialize empty dag
        dag = pydot.Dot(graph_type='digraph', **self.kws['dag'])
        # Initialize nodes
        go2node = self._get_go2pydotnode()
        # Add nodes to graph
        for node in go2node.values():
            dag.add_node(node)
        # Add edges to graph
        rel2edgekws = self.rel2edgekws
        self.edgesobj.chk_edges()
        edgekws = rel2edgekws.get(rel)
        self._add_edges(self.edgesobj.edges, go2node, dag, **edgekws)
        for reltype, edges_list in self.edgesobj.edges_rel.items():
            edgekws = rel2edgekws.get(reltype)
            self._add_edges(edges_list, go2node, dag, **edgekws)
        return dag
34240
def _to_graph(self, contexts):
        """"""
        prev = None

        for context in contexts:
            if prev is None:
                prev = context
                continue

            yield prev[0], context[1], context[0]
            prev = context