| 290 | # Return value of Graph.shortest_paths(). |
| 291 | # Dictionary values can be accessed by Node as well as by node id. |
| 292 | class nodedict(dict): |
| 293 | def __init__(self, graph, *args, **kwargs): |
| 294 | dict.__init__(self, *args, **kwargs) |
| 295 | self.graph = graph |
| 296 | def __contains__(self, node): |
| 297 | return dict.__contains__(self, self.graph.get(node, node)) |
| 298 | def __getitem__(self, node): |
| 299 | return dict.__getitem__(self, isinstance(node, Node) and node or self.graph[node]) |
| 300 | def get(self, node, default=None): |
| 301 | return dict.get(self, self.graph.get(node, node), default) |
| 302 | |
| 303 | def unique(iterable): |
| 304 | """ Returns a list copy in which each item occurs only once (in-order). |
no outgoing calls
no test coverage detected
searching dependent graphs…