Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
SELECT DISTINCT ?parent ?node
FROM
WHERE {
?node skos:broader ?parent
} ORDER BY ?parent
""")
resultsEdges = sparql.query().convert()
for y in resultsEdges["results"]["bindings"]:
g1.add_edge(("/".join(y["parent"]["value"].split("/")[5:]), "/".join(y["node"]["value"].split("/")[5:])))
# Draw as PNG
# print "Writing plot..."
dot = write(g1)
G = pgv.AGraph(dot)
G.layout(prog='dot')
G.draw('../output/foo.png')
print G.string()
# gvv = gv.readstring(dot)
>>> pos = nx.nx_agraph.graphviz_layout(G)
>>> pos = nx.nx_agraph.graphviz_layout(G, prog='dot')
"""
try:
import pygraphviz
except ImportError:
raise ImportError('requires pygraphviz ',
'http://pygraphviz.github.io/')
if root is not None:
args+="-Groot=%s"%root
A=to_agraph(G)
A.layout(prog=prog,args=args)
node_pos={}
for n in G:
node=pygraphviz.Node(A,n)
try:
xx,yy=node.attr["pos"].split(',')
node_pos[n]=(float(xx),float(yy))
except:
print("no position for node",n)
node_pos[n]=(0.0,0.0)
return node_pos
>>> pos=nx.graphviz_layout(G,prog='dot')
"""
try:
import pygraphviz
except ImportError:
raise ImportError('requires pygraphviz ',
'http://networkx.lanl.gov/pygraphviz ',
'(not available for Python3)')
if root is not None:
args+="-Groot=%s"%root
A=to_agraph(G)
A.layout(prog=prog,args=args)
node_pos={}
for n in G:
node=pygraphviz.Node(A,n)
try:
xx,yy=node.attr["pos"].split(',')
node_pos[n]=(float(xx),float(yy))
except:
print("no position for node",n)
node_pos[n]=(0.0,0.0)
return node_pos
>>> pos = nx.nx_agraph.graphviz_layout(G)
>>> pos = nx.nx_agraph.graphviz_layout(G, prog='dot')
"""
try:
import pygraphviz
except ImportError:
raise ImportError('requires pygraphviz ',
'http://pygraphviz.github.io/')
if root is not None:
args+="-Groot=%s"%root
A=to_agraph(G)
A.layout(prog=prog,args=args)
node_pos={}
for n in G:
node=pygraphviz.Node(A,n)
try:
xx,yy=node.attr["pos"].split(',')
node_pos[n]=(float(xx),float(yy))
except:
print("no position for node",n)
node_pos[n]=(0.0,0.0)
return node_pos
H_layout = nx.nx_agraph.pygraphviz_layout(G, prog='dot')
G_layout = {H.nodes[n]['node_label']: p for n, p in H_layout.items()}
"""
try:
import pygraphviz
except ImportError:
raise ImportError('requires pygraphviz ',
'http://pygraphviz.github.io/')
if root is not None:
args += "-Groot=%s" % root
A = to_agraph(G)
A.layout(prog=prog, args=args)
node_pos = {}
for n in G:
node = pygraphviz.Node(A, n)
try:
xs = node.attr["pos"].split(',')
node_pos[n] = tuple(float(x) for x in xs)
except:
print("no position for node", n)
node_pos[n] = (0.0, 0.0)
return node_pos
>>> pos = nx.nx_agraph.graphviz_layout(G)
>>> pos = nx.nx_agraph.graphviz_layout(G, prog='dot')
"""
try:
import pygraphviz
except ImportError:
raise ImportError('requires pygraphviz ',
'http://pygraphviz.github.io/')
if root is not None:
args+="-Groot=%s"%root
A=to_agraph(G)
A.layout(prog=prog,args=args)
node_pos={}
for n in G:
node=pygraphviz.Node(A,n)
try:
xx,yy=node.attr["pos"].split(',')
node_pos[n]=(float(xx),float(yy))
except:
print("no position for node",n)
node_pos[n]=(0.0,0.0)
return node_pos
runprog=r'"%s"'%self._get_prog(prog)
cmd=' '.join([runprog,args])
dotargs = shlex.split(cmd)
p = subprocess.Popen(dotargs,
shell=False,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=False)
(child_stdin,
child_stdout,
child_stderr) = (p.stdin, p.stdout, p.stderr)
# Use threading to avoid blocking
data = []
errors = []
threads = [PipeReader(data, child_stdout),
PipeReader(errors, child_stderr)]
for t in threads:
t.start()
self.write(child_stdin)
child_stdin.close()
for t in threads:
t.join()
if data==[]:
raise IOError(b''.join(errors))
if len(errors)>0:
warnings.warn(b''.join(errors),RuntimeWarning)
return b"".join(data)
cmd = ' '.join([runprog, args])
dotargs = shlex.split(cmd)
p = subprocess.Popen(dotargs,
shell=False,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=False)
(child_stdin,
child_stdout,
child_stderr) = (p.stdin, p.stdout, p.stderr)
# Use threading to avoid blocking
data = []
errors = []
threads = [PipeReader(data, child_stdout),
PipeReader(errors, child_stderr)]
for t in threads:
t.start()
self.write(child_stdin)
child_stdin.close()
for t in threads:
t.join()
p.wait()
if not data:
raise IOError(b"".join(errors).decode(self.encoding))
if len(errors) > 0:
warnings.warn(b"".join(errors).decode(self.encoding), RuntimeWarning)
return b"".join(data)
cmd=' '.join([runprog,args])
dotargs = shlex.split(cmd)
p = subprocess.Popen(dotargs,
shell=False,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=False)
(child_stdin,
child_stdout,
child_stderr) = (p.stdin, p.stdout, p.stderr)
# Use threading to avoid blocking
data = []
errors = []
threads = [PipeReader(data, child_stdout),
PipeReader(errors, child_stderr)]
for t in threads:
t.start()
self.write(child_stdin)
child_stdin.close()
for t in threads:
t.join()
if data==[]:
raise IOError(b''.join(errors))
if len(errors)>0:
warnings.warn(b''.join(errors),RuntimeWarning)
return b"".join(data)
runprog = r'"%s"' % self._get_prog(prog)
cmd = ' '.join([runprog, args])
dotargs = shlex.split(cmd)
p = subprocess.Popen(dotargs,
shell=False,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=False)
(child_stdin,
child_stdout,
child_stderr) = (p.stdin, p.stdout, p.stderr)
# Use threading to avoid blocking
data = []
errors = []
threads = [PipeReader(data, child_stdout),
PipeReader(errors, child_stderr)]
for t in threads:
t.start()
self.write(child_stdin)
child_stdin.close()
for t in threads:
t.join()
p.wait()
if not data:
raise IOError(b"".join(errors).decode(self.encoding))
if len(errors) > 0:
warnings.warn(b"".join(errors).decode(self.encoding), RuntimeWarning)