Beispiel #1
0
 def test_xml_hypergraph(self):
     gr = testlib.new_hypergraph()
     dotstr = markup.write(gr)
     gr1 = markup.read(dotstr)
     dotstr = markup.write(gr1)
     gr2 = markup.read(dotstr)
     graph_equality(gr1, gr2)
 def test_xml_hypergraph(self):
     gr = testlib.new_hypergraph()
     dotstr = markup.write(gr)
     gr1 = markup.read(dotstr)
     dotstr = markup.write(gr1)
     gr2 = markup.read(dotstr)  
     graph_equality(gr1, gr2)
 def test_dot_for_digraph(self):
     gr = testlib.new_digraph()
     dotstr = markup.write(gr)
     gr1 = markup.read(dotstr)
     dotstr = markup.write(gr1)
     gr2 = markup.read(dotstr)  
     graph_equality(gr1, gr2)
Beispiel #4
0
 def test_xml_digraph(self):
     gr = testlib.new_digraph()
     dotstr = markup.write(gr)
     gr1 = markup.read(dotstr)
     dotstr = markup.write(gr1)
     gr2 = markup.read(dotstr)
     graph_equality(gr1, gr2)
     assert len(gr.nodes()) == len(gr1.nodes())
     assert len(gr.edges()) == len(gr1.edges())
 def test_xml_digraph(self):
     gr = testlib.new_digraph()
     dotstr = markup.write(gr)
     gr1 = markup.read(dotstr)
     dotstr = markup.write(gr1)
     gr2 = markup.read(dotstr)  
     graph_equality(gr1, gr2)
     assert len(gr.nodes()) == len(gr1.nodes())
     assert len(gr.edges()) == len(gr1.edges())
Beispiel #6
0
def demo():
    """A demo function to show what this module can do."""

    # Supported data structre.
    dictionary = {
        u'а': {u'атака': [u'тест 1', u'тест 2', u'тест 3',],
               u'апогей': [u'тест 4', u'тест 5'],
               u'ананас': [u'тест 6', u'тест 7'],
        }
    }

    print 'The Undirected Graph Dict:'
    test = UndirectedGraphDict()
    test.create(dictionary)

    print markup.write(test.get_graph)
    print "*" * 80

    print 'the Directed Graph Dict:'
    test_2 = DirectedGraphDict()
    test_2.create(dictionary)
    print markup.write(test_2.get_graph)

    print '-------------------'
    print 'Spanning Tree:'
    print markup.write(test_2.get_word_st(u'атака'))
Beispiel #7
0
def depmake(db, config, args):
    """
    Parse the CLI arguments and invoke the 'makedepgraph' function.
    """
    (options, req_ruleset, components_lists) = _parse_depmake_cmdline(config,
                                                                      args)

    rules = db.get_rules_for(req_ruleset)
    dag = None
    depgraph = None
    # Provide the graphing capability even in the case of a
    # CycleDetectedError. Graph can be used to visualize such cycles.
    try:
        depgraph = makedepgraph(config, rules, components_lists, options)
        dag = depgraph.dag
    except CyclesDetectedError as cde:
        # A cycle leads to an error, since it prevents the normal
        # execution.
        _LOGGER.critical(str(cde))
        dag = cde.graph

    # Only execute when the depgraph is available (no cycle detected)
    if depgraph is not None:
        dst = options.out
        _LOGGER.debug("Writing to: %s", dst)

        strgraph = convert_uni_graph_to_str(depgraph.dag)
        output = write(strgraph)
        if dst == '-':
            _LOGGER.output(output)
        else:
            print(output, file=open(dst, "w"))


    # The DOT graph is written afterwards for two reasons:
    #
    # 1. since the XML graph has already been written out, we can
    # modify the model for vizualisation (removing attributes, see
    # 'write_graph_to');
    #
    # 2. if an error occurs in next steps, it does not prevent the XML
    # graph from being used.
    if options.depgraphto is not None:
        write_graph_to(dag, options.depgraphto)

    return os.EX_OK if depgraph is not None else os.EX_DATAERR
Beispiel #8
0
	parent_url = entry['parent']		#Parent 
	url = entry['url']							#Child

	#URLs were not normalized to end with a slash at the end. We do an OR
	#query for both versions of the URL. 
	if parent_url[-1] == u'/':
		alt = parent_url[:-1]
	else:
		alt = parent_url + u'/'

	#Find docID corresponding to child URL.
	url_docID_entry = db.docIDs.find( {"url" : entry['url']} )[0]
	url_docID = int(url_docID_entry['docID'])

	try : 
		parent_docID_entry = db.docIDs.find( { '$or' : [ {"url" : parent_url}, {"url" : alt } ] } )[0]
		parent_docID = int(parent_docID_entry['docID'])
	except : 
		i += 1
		continue

	espn_graph.add_edge( [parent_docID, url_docID] )
	i += 1
	
graph_xml = write(espn_graph)

graph_xml_file = open("graph_xml", "w")
graph_xml_file.write(graph_xml)

connection.disconnect()
Beispiel #9
0
	def to_XML(self):
		graph = self.core
		write(graph)