def _dot_node(self, uri, attrs): node = Node(uri, attrs) if self.tooltips[uri]: node.update({"tooltip": " ".join(self.tooltips[uri])}) if isinstance(uri, BNode) or self.config.bnode_regex_match(uri): node.update({"label": "", "shape": "circle"}) return node.to_draw() node.update( {"label": self.compute_label(uri, self.config.max_label_length)}) return node.to_draw()
def convert(self): node_strings = [] edge_strings = [] for class_ in self.classes: node_strings.append(self._dot_class_node(class_)) for instance, class_ in self.instances.items(): node_strings.append(self._dot_instance_node(instance, class_)) for uri, literal in self.literals: node = Node(uri, node_color(self.config.colors.lit)) node.update({ "label": text_justify(literal, self.config.max_label_length), "shape": "rect" }) node_strings.append(node.to_draw()) for s, p, o in self.edges: edge_strings.append(' "{}" -> "{}" [label="{}"]'.format(s, o, self._pred_label(p))) return node_strings, edge_strings
import sys from graph_element import Edge, Node from ford_fulkerson import ford_fulkerson sys.setrecursionlimit(10**9) N, M, C, P = list(map(int, sys.stdin.readline().strip().split(' '))) input = sys.stdin.readlines() graph = {} nodes = [Node(n) for n in range(N)] edges = [0] * M for i in range(M): dest1, dest2, cap = map(int, input[i].strip().split(' ')) edges[i] = Edge(nodes[dest1], nodes[dest2], cap) P_edges = [int(line.strip()) for line in input[M:]] def update_graph(edge): from_node, to_node = edge.destination1, edge.destination2 if from_node.index not in graph: from_node.edges.append(edge) graph[from_node.index] = from_node else: graph[from_node.index].edges.append(edge) if to_node.index not in graph: to_node.edges.append(edge) graph[to_node.index] = to_node else: graph[to_node.index].edges.append(edge)