code string | signature string | docstring string | loss_without_docstring float64 | loss_with_docstring float64 | factor float64 |
|---|---|---|---|---|---|
'''
API: add_left_child(self, n, parent, **attrs)
Description:
Adds left child n to node parent.
Pre:
Left child of parent should not exist.
Input:
n: Node name.
parent: Parent node name.
attrs: Attributes of node n.
... | def add_left_child(self, n, parent, **attrs) | API: add_left_child(self, n, parent, **attrs)
Description:
Adds left child n to node parent.
Pre:
Left child of parent should not exist.
Input:
n: Node name.
parent: Parent node name.
attrs: Attributes of node n. | 3.761977 | 2.283792 | 1.64725 |
'''
API: get_right_child(self, n)
Description:
Returns right child of node n. n can be Node() instance or string
(name of node).
Pre:
Node n should be present in the tree.
Input:
n: Node name or Node() instance.
Return:
... | def get_right_child(self, n) | API: get_right_child(self, n)
Description:
Returns right child of node n. n can be Node() instance or string
(name of node).
Pre:
Node n should be present in the tree.
Input:
n: Node name or Node() instance.
Return:
Returns name... | 5.030484 | 1.890904 | 2.66036 |
'''
API: get_left_child(self, n)
Description:
Returns left child of node n. n can be Node() instance or string
(name of node).
Pre:
Node n should be present in the tree.
Input:
n: Node name or Node() instance.
Return:
... | def get_left_child(self, n) | API: get_left_child(self, n)
Description:
Returns left child of node n. n can be Node() instance or string
(name of node).
Pre:
Node n should be present in the tree.
Input:
n: Node name or Node() instance.
Return:
Returns name o... | 4.921378 | 1.83563 | 2.68103 |
'''
API: del_node(self, n)
Description:
Removes node n from tree.
Pre:
Node n should be present in the tree.
Input:
n: Node name.
'''
parent = self.get_node_attr(n, 'parent')
if self.get_node_attr(n, 'direction') == 'R':... | def del_node(self, n) | API: del_node(self, n)
Description:
Removes node n from tree.
Pre:
Node n should be present in the tree.
Input:
n: Node name. | 3.395035 | 2.242 | 1.514289 |
'''
API: print_nodes(self, order = 'in', priority = 'L', display = None,
root = None)
Description:
A recursive function that prints nodes to stdout starting from
root.
Input:
order: Order of printing. Acceptable arguments are 'pre',... | def print_nodes(self, order = 'in', priority = 'L', display = None,
root = None) | API: print_nodes(self, order = 'in', priority = 'L', display = None,
root = None)
Description:
A recursive function that prints nodes to stdout starting from
root.
Input:
order: Order of printing. Acceptable arguments are 'pre', 'in',
'... | 2.182933 | 1.611985 | 1.35419 |
'''
API: dfs(self, root=None, display=None, priority='L', order='in')
Description:
Searches tree starting from node named root using depth-first
strategy if root argument is provided. Starts search from root node
of the tree otherwise.
Input:
... | def dfs(self, root = None, display = None, priority = 'L') | API: dfs(self, root=None, display=None, priority='L', order='in')
Description:
Searches tree starting from node named root using depth-first
strategy if root argument is provided. Starts search from root node
of the tree otherwise.
Input:
root: Starting no... | 7.447796 | 1.649723 | 4.514575 |
'''
API: bfs(self, root=None, display=None, priority='L', order='in')
Description:
Searches tree starting from node named root using breadth-first
strategy if root argument is provided. Starts search from root node
of the tree otherwise.
Input:
... | def bfs(self, root = None, display = None, priority = 'L') | API: bfs(self, root=None, display=None, priority='L', order='in')
Description:
Searches tree starting from node named root using breadth-first
strategy if root argument is provided. Starts search from root node
of the tree otherwise.
Input:
root: Starting ... | 6.722818 | 1.616399 | 4.159133 |
'''
API: traverse(self, root=None, display=None, q=Stack(), priority='L',
order='in')
Description:
Traverses tree starting from node named root if root argument is
provided. Starts search from root node of the tree otherwise. Search
strat... | def traverse(self, root = None, display = None, q = Stack(),
priority = 'L') | API: traverse(self, root=None, display=None, q=Stack(), priority='L',
order='in')
Description:
Traverses tree starting from node named root if root argument is
provided. Starts search from root node of the tree otherwise. Search
strategy is determined by... | 3.22635 | 1.621355 | 1.989909 |
ytxt = yfile.read()
mp = ModuleParser(ytxt)
mst = mp.statement()
submod = mst.keyword == "submodule"
import_only = True
rev = ""
features = []
includes = []
rec = {}
for sst in mst.substatements:
if not rev and sst.keyword == "revision":
rev = sst.argumen... | def module_entry(yfile) | Add entry for one file containing YANG module text.
Args:
yfile (file): File containing a YANG module or submodule. | 3.731242 | 3.742585 | 0.996969 |
return (not self.check_when() or self.pattern.nullable(ctype)) | def nullable(self, ctype: ContentType) -> bool | Override the superclass method. | 30.960924 | 18.129307 | 1.707783 |
return (self.pattern.deriv(x, ctype) if self.check_when() else
NotAllowed()) | def deriv(self, x: str, ctype: ContentType) -> SchemaPattern | Return derivative of the receiver. | 17.001589 | 13.723486 | 1.238868 |
return (Empty() if
self.name == x and self._active(ctype)
else NotAllowed()) | def deriv(self, x: str, ctype: ContentType) -> SchemaPattern | Return derivative of the receiver. | 32.091141 | 26.884295 | 1.193676 |
return self.left.nullable(ctype) or self.right.nullable(ctype) | def nullable(self, ctype: ContentType) -> bool | Override the superclass method. | 7.20571 | 3.965804 | 1.816961 |
return Alternative.combine(self.left.deriv(x, ctype),
self.right.deriv(x, ctype)) | def deriv(self, x: str, ctype: ContentType) -> SchemaPattern | Return derivative of the receiver. | 5.729559 | 5.027389 | 1.139669 |
with open(name, encoding="utf-8") as infile:
yltxt = infile.read()
return cls(yltxt, mod_path, description) | def from_file(cls, name: str, mod_path: Tuple[str] = (".",),
description: str = None) -> "DataModel" | Initialize the data model from a file with YANG library data.
Args:
name: Name of a file with YANG library data.
mod_path: Tuple of directories where to look for YANG modules.
description: Optional description of the data model.
Returns:
The data model ... | 5.958379 | 6.355793 | 0.937472 |
fnames = sorted(["@".join(m) for m in self.schema_data.modules])
return hashlib.sha1("".join(fnames).encode("ascii")).hexdigest() | def module_set_id(self) -> str | Compute unique id of YANG modules comprising the data model.
Returns:
String consisting of hexadecimal digits. | 9.737009 | 9.013016 | 1.080328 |
cooked = self.schema.from_raw(robj)
return RootNode(cooked, self.schema, cooked.timestamp) | def from_raw(self, robj: RawObject) -> RootNode | Create an instance node from a raw data tree.
Args:
robj: Dictionary representing a raw data tree.
Returns:
Root instance node. | 7.854918 | 8.744455 | 0.898274 |
return self.schema.get_schema_descendant(
self.schema_data.path2route(path)) | def get_schema_node(self, path: SchemaPath) -> Optional[SchemaNode] | Return the schema node addressed by a schema path.
Args:
path: Schema path.
Returns:
Schema node if found in the schema, or ``None``.
Raises:
InvalidSchemaPath: If the schema path is invalid. | 16.079878 | 29.168526 | 0.551275 |
addr = self.schema_data.path2route(path)
node = self.schema
for p in addr:
node = node.get_data_child(*p)
if node is None:
return None
return node | def get_data_node(self, path: DataPath) -> Optional[DataNode] | Return the data node addressed by a data path.
Args:
path: Data path.
Returns:
Data node if found in the schema, or ``None``.
Raises:
InvalidSchemaPath: If the schema path is invalid. | 6.575348 | 6.718305 | 0.978721 |
return self.schema._ascii_tree("", no_types, val_count) | def ascii_tree(self, no_types: bool = False, val_count: bool = False) -> str | Generate ASCII art representation of the schema tree.
Args:
no_types: Suppress output of data type info.
val_count: Show accumulated validation counts.
Returns:
String with the ASCII tree. | 12.645794 | 10.341259 | 1.222849 |
res = self.schema._node_digest()
res["config"] = True
return json.dumps(res) | def schema_digest(self) -> str | Generate schema digest (to be used primarily by clients).
Returns:
Condensed information about the schema in JSON format. | 16.179539 | 15.186708 | 1.065375 |
if self.test_string("*"):
self.skip_ws()
return False
ident = self.yang_identifier()
ws = self.skip_ws()
try:
next = self.peek()
except EndOfInput:
return ident, None
if next == "(":
return self._node_ty... | def _qname(self) -> Optional[QualName] | Parse XML QName. | 6.518707 | 5.995004 | 1.087357 |
# If the name is a reserved keyword it will need quotes but pydot
# can't tell when it's being used as a keyword or when it's simply
# a name. Hence the user needs to supply the quotes when an element
# would use a reserved keyword as name. This function will return
# false indicating that a ke... | def needs_quotes(s) | Checks whether a string is a dot language ID.
It will check whether the string is solely composed
by the characters allowed in an ID or not.
If the string is one of the reserved keywords it will
need quotes too but the user will need to add them
manually. | 5.292241 | 4.905153 | 1.078914 |
'''
API: to_string(self)
Description:
Returns string representation of node in dot language.
Return:
String representation of node.
'''
node = list()
node.append(quote_if_necessary(str(self.name)))
node.append(' [')
flag = False... | def to_string(self) | API: to_string(self)
Description:
Returns string representation of node in dot language.
Return:
String representation of node. | 3.068054 | 2.286841 | 1.341613 |
'''
API: add_node(self, name, **attr)
Description:
Adds node to the graph.
Pre:
Graph should not contain a node with this name. We do not allow
multiple nodes with the same name.
Input:
name: Name of the node.
attr: Node att... | def add_node(self, name, **attr) | API: add_node(self, name, **attr)
Description:
Adds node to the graph.
Pre:
Graph should not contain a node with this name. We do not allow
multiple nodes with the same name.
Input:
name: Name of the node.
attr: Node attributes.
Pos... | 4.14364 | 1.847141 | 2.243272 |
'''
API: del_node(self, name)
Description:
Removes node from Graph.
Input:
name: Name of the node.
Pre:
Graph should contain a node with this name.
Post:
self.neighbors, self.nodes and self.in_neighbors are updated.
'''
... | def del_node(self, name) | API: del_node(self, name)
Description:
Removes node from Graph.
Input:
name: Name of the node.
Pre:
Graph should contain a node with this name.
Post:
self.neighbors, self.nodes and self.in_neighbors are updated. | 2.796906 | 1.922394 | 1.454908 |
'''
API: add_edge(self, name1, name2, **attr)
Description:
Adds edge to the graph. Sets edge attributes using attr argument.
Input:
name1: Name of the source node (if directed).
name2: Name of the sink node (if directed).
attr: Edge attributes.... | def add_edge(self, name1, name2, **attr) | API: add_edge(self, name1, name2, **attr)
Description:
Adds edge to the graph. Sets edge attributes using attr argument.
Input:
name1: Name of the source node (if directed).
name2: Name of the sink node (if directed).
attr: Edge attributes.
Pre:
... | 2.929578 | 1.583408 | 1.850172 |
'''
API: del_edge(self, e)
Description:
Removes edge from graph.
Input:
e: Tuple that represents edge, in (source,sink) form.
Pre:
Graph should contain this edge.
Post:
self.edge_attr, self.neighbors and self.in_neighbors are up... | def del_edge(self, e) | API: del_edge(self, e)
Description:
Removes edge from graph.
Input:
e: Tuple that represents edge, in (source,sink) form.
Pre:
Graph should contain this edge.
Post:
self.edge_attr, self.neighbors and self.in_neighbors are updated. | 2.685946 | 1.673362 | 1.60512 |
'''
API: check_edge(self, name1, name2)
Description:
Return True if edge exists, False otherwise.
Input:
name1: name of the source node.
name2: name of the sink node.
Return:
Returns True if edge exists, False otherwise.
'''
... | def check_edge(self, name1, name2) | API: check_edge(self, name1, name2)
Description:
Return True if edge exists, False otherwise.
Input:
name1: name of the source node.
name2: name of the sink node.
Return:
Returns True if edge exists, False otherwise. | 2.860286 | 2.07693 | 1.37717 |
'''
API: get_edge_attr(self, n, m, attr)
Description:
Returns attribute attr of edge (n,m).
Input:
n: Source node name.
m: Sink node name.
attr: Attribute of edge.
Pre:
Graph should have this edge.
Return:
... | def get_edge_attr(self, n, m, attr) | API: get_edge_attr(self, n, m, attr)
Description:
Returns attribute attr of edge (n,m).
Input:
n: Source node name.
m: Sink node name.
attr: Attribute of edge.
Pre:
Graph should have this edge.
Return:
Value of edge attr... | 3.611758 | 1.839423 | 1.963527 |
'''
API: set_node_attr(self, name, attr)
Description:
Sets attr attribute of node named name to value.
Input:
name: Name of node.
attr: Attribute of node to set.
Pre:
Graph should have this node.
Post:
Node attribute... | def set_node_attr(self, name, attr, value) | API: set_node_attr(self, name, attr)
Description:
Sets attr attribute of node named name to value.
Input:
name: Name of node.
attr: Attribute of node to set.
Pre:
Graph should have this node.
Post:
Node attribute will be updated. | 5.212223 | 1.939586 | 2.687286 |
'''
API: set_edge_attr(self, n, m, attr, value)
Description:
Sets attr attribute of edge (n,m) to value.
Input:
n: Source node name.
m: Sink node name.
attr: Attribute of edge to set.
value: New value of attribute.
Pre:
... | def set_edge_attr(self, n, m, attr, value) | API: set_edge_attr(self, n, m, attr, value)
Description:
Sets attr attribute of edge (n,m) to value.
Input:
n: Source node name.
m: Sink node name.
attr: Attribute of edge to set.
value: New value of attribute.
Pre:
Graph should... | 3.327443 | 1.77809 | 1.871358 |
'''
API: edge_to_string(self, e)
Description:
Return string that represents edge e in dot language.
Input:
e: Edge tuple in (source,sink) format.
Pre:
Graph should have this edge.
Return:
String that represents given edge.
... | def edge_to_string(self, e) | API: edge_to_string(self, e)
Description:
Return string that represents edge e in dot language.
Input:
e: Edge tuple in (source,sink) format.
Pre:
Graph should have this edge.
Return:
String that represents given edge. | 3.306639 | 2.098221 | 1.575925 |
'''
API: to_string(self)
Description:
This method is based on pydot Graph class with the same name.
Returns a string representation of the graph in dot language.
It will return the graph and all its subelements in string form.
Return:
String that repre... | def to_string(self) | API: to_string(self)
Description:
This method is based on pydot Graph class with the same name.
Returns a string representation of the graph in dot language.
It will return the graph and all its subelements in string form.
Return:
String that represents graph in dot l... | 2.446352 | 1.998751 | 1.22394 |
'''
API: label_components(self, display=None)
Description:
This method labels the nodes of an undirected graph with component
numbers so that each node has the same label as all nodes in the
same component. It will display the algortihm if display argument is
prov... | def label_components(self, display = None) | API: label_components(self, display=None)
Description:
This method labels the nodes of an undirected graph with component
numbers so that each node has the same label as all nodes in the
same component. It will display the algortihm if display argument is
provided.
Input:... | 4.28074 | 2.011622 | 2.128004 |
'''
API: tarjan(self)
Description:
Implements Tarjan's algorithm for determining strongly connected set of
nodes.
Pre:
self.graph_type should be DIRECTED_GRAPH.
Post:
Nodes will have 'component' attribute that will have component
... | def tarjan(self) | API: tarjan(self)
Description:
Implements Tarjan's algorithm for determining strongly connected set of
nodes.
Pre:
self.graph_type should be DIRECTED_GRAPH.
Post:
Nodes will have 'component' attribute that will have component
number as value. C... | 6.431272 | 2.194255 | 2.930959 |
'''
API: strong_connect (self, q, node, index, component)
Description:
Used by tarjan method. This method should not be called directly by
user.
Input:
q: Node list.
node: Node that is being connected to nodes in q.
index: Index used by... | def strong_connect(self, q, node, index, component) | API: strong_connect (self, q, node, index, component)
Description:
Used by tarjan method. This method should not be called directly by
user.
Input:
q: Node list.
node: Node that is being connected to nodes in q.
index: Index used by tarjan method.
... | 2.77207 | 1.544648 | 1.794629 |
'''
API: dfs(self, root, disc_count = 0, finish_count = 1, component=None,
transpose=False)
Description:
Make a depth-first search starting from node with name root.
Input:
root: Starting node name.
disc_count: Discovery time.
finis... | def dfs(self, root, disc_count = 0, finish_count = 1, component = None,
transpose = False, display = None, pred = None) | API: dfs(self, root, disc_count = 0, finish_count = 1, component=None,
transpose=False)
Description:
Make a depth-first search starting from node with name root.
Input:
root: Starting node name.
disc_count: Discovery time.
finish_count: Finishing t... | 2.723502 | 1.832342 | 1.48635 |
'''
API: bfs(self, root, display = None, component=None)
Description:
Make a breadth-first search starting from node with name root.
Input:
root: Starting node name.
display: display method.
component: component number.
Post:
... | def bfs(self, root, display = None, component = None) | API: bfs(self, root, display = None, component=None)
Description:
Make a breadth-first search starting from node with name root.
Input:
root: Starting node name.
display: display method.
component: component number.
Post:
Nodes will have 'c... | 6.488946 | 1.823657 | 3.558206 |
'''
API: process_node_search(self, node, q, **kwargs)
Description:
Used by search() method. Process nodes along the search. Should not be
called by user directly.
Input:
node: Name of the node being processed.
q: Queue data structure.
k... | def process_node_search(self, node, q, **kwargs) | API: process_node_search(self, node, q, **kwargs)
Description:
Used by search() method. Process nodes along the search. Should not be
called by user directly.
Input:
node: Name of the node being processed.
q: Queue data structure.
kwargs: Keyword argum... | 7.420654 | 1.938396 | 3.828245 |
'''
API: process_edge_dijkstra(self, current, neighbor, pred, q, component)
Description:
Used by search() method if the algo argument is 'Dijkstra'. Processes
edges along Dijkstra's algorithm. User does not need to call this
method directly.
Input:
cur... | def process_edge_dijkstra(self, current, neighbor, pred, q, component) | API: process_edge_dijkstra(self, current, neighbor, pred, q, component)
Description:
Used by search() method if the algo argument is 'Dijkstra'. Processes
edges along Dijkstra's algorithm. User does not need to call this
method directly.
Input:
current: Name of the cu... | 3.160255 | 1.741176 | 1.815012 |
'''
API: process_edge_search(self, current, neighbor, pred, q, component,
algo, **kargs)
Description:
Used by search() method. Processes edges according to the underlying
algortihm. User does not need to call this method directly.
Input:
... | def process_edge_search(self, current, neighbor, pred, q, component, algo,
**kargs) | API: process_edge_search(self, current, neighbor, pred, q, component,
algo, **kargs)
Description:
Used by search() method. Processes edges according to the underlying
algortihm. User does not need to call this method directly.
Input:
current: ... | 2.63143 | 1.809478 | 1.454248 |
'''
API: minimum_spanning_tree_prim(self, source, display = None,
q = PriorityQueue())
Description:
Determines a minimum spanning tree of all nodes reachable
from source using Prim's Algorithm.
Input:
source: Name of sou... | def minimum_spanning_tree_prim(self, source, display = None,
q = PriorityQueue()) | API: minimum_spanning_tree_prim(self, source, display = None,
q = PriorityQueue())
Description:
Determines a minimum spanning tree of all nodes reachable
from source using Prim's Algorithm.
Input:
source: Name of source node.
... | 3.121162 | 2.104199 | 1.483302 |
'''
API: minimum_spanning_tree_kruskal(self, display = None,
components = None)
Description:
Determines a minimum spanning tree using Kruskal's Algorithm.
Input:
display: Display method.
component: component numbe... | def minimum_spanning_tree_kruskal(self, display = None, components = None) | API: minimum_spanning_tree_kruskal(self, display = None,
components = None)
Description:
Determines a minimum spanning tree using Kruskal's Algorithm.
Input:
display: Display method.
component: component number.
Post:
... | 3.276543 | 2.070508 | 1.582482 |
'''
API: process_edge_flow(self, source, sink, i, j, algo, q)
Description:
Used by by max_flow_preflowpush() method. Processes edges along
prefolow push.
Input:
source: Source node name of flow graph.
sink: Sink node name of flow graph.
... | def process_edge_flow(self, source, sink, i, j, algo, q) | API: process_edge_flow(self, source, sink, i, j, algo, q)
Description:
Used by by max_flow_preflowpush() method. Processes edges along
prefolow push.
Input:
source: Source node name of flow graph.
sink: Sink node name of flow graph.
i: Source node in t... | 3.295269 | 1.730295 | 1.904456 |
'''
API: relabel(self, i)
Description:
Used by max_flow_preflowpush() method for relabelling node i.
Input:
i: Node that is being relabelled.
Post:
'distance' attribute of node i is updated.
'''
min_distance = 2*len(self.get_node_li... | def relabel(self, i) | API: relabel(self, i)
Description:
Used by max_flow_preflowpush() method for relabelling node i.
Input:
i: Node that is being relabelled.
Post:
'distance' attribute of node i is updated. | 2.859668 | 1.708106 | 1.674175 |
'''
API: relabel(self, i)
Description:
Used by max_flow_preflowpush() method for display purposed.
Post:
'color' and 'label' attribute of edges/nodes are updated.
'''
for n in self.get_node_list():
excess = self.get_node_attr(n, 'excess')
... | def show_flow(self) | API: relabel(self, i)
Description:
Used by max_flow_preflowpush() method for display purposed.
Post:
'color' and 'label' attribute of edges/nodes are updated. | 3.015152 | 1.81994 | 1.656731 |
'''
API: create_residual_graph(self)
Description:
Creates and returns residual graph, which is a Graph instance
itself.
Pre:
(1) Arcs should have 'flow', 'capacity' and 'cost' attribute
(2) Graph should be a directed graph
Return:
... | def create_residual_graph(self) | API: create_residual_graph(self)
Description:
Creates and returns residual graph, which is a Graph instance
itself.
Pre:
(1) Arcs should have 'flow', 'capacity' and 'cost' attribute
(2) Graph should be a directed graph
Return:
Returns residual ... | 3.132405 | 1.957541 | 1.600173 |
'''
API:
cycle_canceling(self, display)
Description:
Solves minimum cost feasible flow problem using cycle canceling
algorithm. Returns True when an optimal solution is found, returns
False otherwise. 'flow' attribute values of arcs should be
... | def cycle_canceling(self, display) | API:
cycle_canceling(self, display)
Description:
Solves minimum cost feasible flow problem using cycle canceling
algorithm. Returns True when an optimal solution is found, returns
False otherwise. 'flow' attribute values of arcs should be
considered as... | 4.97796 | 1.846558 | 2.695805 |
'''
API:
find_feasible_flow(self)
Description:
Solves feasible flow problem, stores solution in 'flow' attribute
or arcs. This method is used to get an initial feasible flow for
simplex and cycle canceling algorithms. Uses max_flow() method.
... | def find_feasible_flow(self) | API:
find_feasible_flow(self)
Description:
Solves feasible flow problem, stores solution in 'flow' attribute
or arcs. This method is used to get an initial feasible flow for
simplex and cycle canceling algorithms. Uses max_flow() method.
Other max flow... | 4.457194 | 2.211673 | 2.015305 |
'''
API:
write(self, basename = 'graph', layout = None, format='png')
Description:
Writes graph to dist using layout and format.
Input:
basename: name of the file that will be written.
layout: Dot layout for generating graph image.
... | def write(self, basename = 'graph', layout = None, format='png') | API:
write(self, basename = 'graph', layout = None, format='png')
Description:
Writes graph to dist using layout and format.
Input:
basename: name of the file that will be written.
layout: Dot layout for generating graph image.
format: Image format... | 5.388762 | 1.878905 | 2.868033 |
'''
API:
create(self, layout, format, **args)
Description:
Returns postscript representation of graph.
Input:
layout: Dot layout for generating graph image.
format: Image format, all format supported by Dot are wellcome.
Return:
... | def create(self, layout, format, **args) | API:
create(self, layout, format, **args)
Description:
Returns postscript representation of graph.
Input:
layout: Dot layout for generating graph image.
format: Image format, all format supported by Dot are wellcome.
Return:
Returns pos... | 3.923897 | 2.721285 | 1.441928 |
'''
API:
get_negative_cycle(self)
Description:
Finds and returns negative cost cycle using 'cost' attribute of
arcs. Return value is a list of nodes representing cycle it is in
the following form; n_1-n_2-...-n_k, when the cycle has k nodes.
... | def get_negative_cycle(self) | API:
get_negative_cycle(self)
Description:
Finds and returns negative cost cycle using 'cost' attribute of
arcs. Return value is a list of nodes representing cycle it is in
the following form; n_1-n_2-...-n_k, when the cycle has k nodes.
Pre:
A... | 7.042229 | 2.217186 | 3.176201 |
'''
API:
floyd_warshall(self)
Description:
Finds all pair shortest paths and stores it in a list of lists.
This is possible if the graph does not have negative cycles. It will
return a tuple with 3 elements. The first element indicates whether
... | def floyd_warshall(self) | API:
floyd_warshall(self)
Description:
Finds all pair shortest paths and stores it in a list of lists.
This is possible if the graph does not have negative cycles. It will
return a tuple with 3 elements. The first element indicates whether
the graph ha... | 3.135158 | 1.527739 | 2.052155 |
'''
API:
floyd_warshall_get_path(self, distance, nextn, i, j):
Description:
Finds shortest path between i and j using distance and nextn
dictionaries.
Pre:
(1) distance and nextn are outputs of floyd_warshall method.
(2) The gra... | def floyd_warshall_get_path(self, distance, nextn, i, j) | API:
floyd_warshall_get_path(self, distance, nextn, i, j):
Description:
Finds shortest path between i and j using distance and nextn
dictionaries.
Pre:
(1) distance and nextn are outputs of floyd_warshall method.
(2) The graph does not have a n... | 4.303056 | 1.741931 | 2.470279 |
'''
API:
floyd_warshall_get_cycle(self, distance, nextn, element = None)
Description:
Finds a negative cycle in the graph.
Pre:
(1) distance and nextn are outputs of floyd_warshall method.
(2) The graph should have a negative cycle, , ie.
... | def floyd_warshall_get_cycle(self, distance, nextn, element = None) | API:
floyd_warshall_get_cycle(self, distance, nextn, element = None)
Description:
Finds a negative cycle in the graph.
Pre:
(1) distance and nextn are outputs of floyd_warshall method.
(2) The graph should have a negative cycle, , ie.
distance[... | 3.820863 | 1.974655 | 1.934952 |
'''
API:
find_cycle_capacity(self, cycle):
Description:
Finds capacity of the cycle input.
Pre:
(1) Arcs should have 'capacity' attribute.
Input:
cycle: a list representing a cycle
Return:
Returns an integer numb... | def find_cycle_capacity(self, cycle) | API:
find_cycle_capacity(self, cycle):
Description:
Finds capacity of the cycle input.
Pre:
(1) Arcs should have 'capacity' attribute.
Input:
cycle: a list representing a cycle
Return:
Returns an integer number representing capa... | 3.652615 | 1.89743 | 1.925033 |
'''
API:
fifo_label_correcting(self, source)
Description:
finds shortest path from source to every other node. Returns
predecessor dictionary. If graph has a negative cycle, detects it
and returns to it.
Pre:
(1) 'cost' attribut... | def fifo_label_correcting(self, source) | API:
fifo_label_correcting(self, source)
Description:
finds shortest path from source to every other node. Returns
predecessor dictionary. If graph has a negative cycle, detects it
and returns to it.
Pre:
(1) 'cost' attribute of arcs. It will b... | 3.693858 | 1.629119 | 2.267396 |
'''
API:
label_correcting_check_cycle(self, j, pred)
Description:
Checks if predecessor dictionary has a cycle, j represents the node
that predecessor is recently updated.
Pre:
(1) predecessor of source node should be None.
Input:
... | def label_correcting_check_cycle(self, j, pred) | API:
label_correcting_check_cycle(self, j, pred)
Description:
Checks if predecessor dictionary has a cycle, j represents the node
that predecessor is recently updated.
Pre:
(1) predecessor of source node should be None.
Input:
j: node t... | 5.081563 | 1.85472 | 2.7398 |
'''
API:
label_correcting_get_cycle(self, labelled, pred)
Description:
In label correcting check cycle it is decided pred has a cycle and
nodes in the cycle are labelled. We will create a list of nodes
in the cycle using labelled and pred inputs.
... | def label_correcting_get_cycle(self, j, pred) | API:
label_correcting_get_cycle(self, labelled, pred)
Description:
In label correcting check cycle it is decided pred has a cycle and
nodes in the cycle are labelled. We will create a list of nodes
in the cycle using labelled and pred inputs.
Pre:
... | 7.09359 | 1.345023 | 5.273956 |
'''
API:
augment_cycle(self, amount, cycle):
Description:
Augments 'amount' unit of flow along cycle.
Pre:
Arcs should have 'flow' attribute.
Inputs:
amount: An integer representing the amount to augment
cycle: A list re... | def augment_cycle(self, amount, cycle) | API:
augment_cycle(self, amount, cycle):
Description:
Augments 'amount' unit of flow along cycle.
Pre:
Arcs should have 'flow' attribute.
Inputs:
amount: An integer representing the amount to augment
cycle: A list representing a cycle
... | 2.339108 | 1.518895 | 1.540006 |
'''
API:
network_simplex(self, display, pivot, root)
Description:
Solves minimum cost feasible flow problem using network simplex
algorithm. It is recommended to use min_cost_flow(algo='simplex')
instead of using network_simplex() directly. Returns... | def network_simplex(self, display, pivot, root) | API:
network_simplex(self, display, pivot, root)
Description:
Solves minimum cost feasible flow problem using network simplex
algorithm. It is recommended to use min_cost_flow(algo='simplex')
instead of using network_simplex() directly. Returns True when an
... | 5.500393 | 2.613411 | 2.104679 |
'''
API:
simplex_determine_leaving_arc(self, t, k, l)
Description:
Determines and returns the leaving arc.
Input:
t: current spanning tree solution.
k: tail of the entering arc.
l: head of the entering arc.
Return:
... | def simplex_determine_leaving_arc(self, t, k, l) | API:
simplex_determine_leaving_arc(self, t, k, l)
Description:
Determines and returns the leaving arc.
Input:
t: current spanning tree solution.
k: tail of the entering arc.
l: head of the entering arc.
Return:
Returns the t... | 2.73461 | 2.152094 | 1.270674 |
'''
API:
simplex_mark_st_arcs(self, t)
Description:
Marks spanning tree arcs.
Case 1, Blue: Arcs that are at lower bound and in tree.
Case 2, Red: Arcs that are at upper bound and in tree.
Case 3, Green: Arcs that are between bounds are... | def simplex_mark_st_arcs(self, t) | API:
simplex_mark_st_arcs(self, t)
Description:
Marks spanning tree arcs.
Case 1, Blue: Arcs that are at lower bound and in tree.
Case 2, Red: Arcs that are at upper bound and in tree.
Case 3, Green: Arcs that are between bounds are green.
... | 3.269623 | 1.77105 | 1.84615 |
'''
API:
print_flow(self)
Description:
Prints all positive flows to stdout. This method can be used for
debugging purposes.
'''
print('printing current edge, flow, capacity')
for e in self.edge_attr:
if self.edge_attr[e]['fl... | def print_flow(self) | API:
print_flow(self)
Description:
Prints all positive flows to stdout. This method can be used for
debugging purposes. | 4.723442 | 3.226937 | 1.463754 |
'''
API:
simplex_redraw(self, display, root)
Description:
Returns a new graph instance that is same as self but adds nodes
and arcs in a way that the resulting tree will be displayed
properly.
Input:
display: display mode
... | def simplex_redraw(self, display, root) | API:
simplex_redraw(self, display, root)
Description:
Returns a new graph instance that is same as self but adds nodes
and arcs in a way that the resulting tree will be displayed
properly.
Input:
display: display mode
root: root nod... | 2.537801 | 1.929724 | 1.315111 |
'''
API:
simplex_remove_arc(self, p, q, min_capacity, cycle)
Description:
Removes arc (p,q), updates t, updates flows, where (k,l) is
the entering arc.
Input:
t: tree solution to be updated.
p: tail of the leaving arc.
... | def simplex_remove_arc(self, t, p, q, min_capacity, cycle) | API:
simplex_remove_arc(self, p, q, min_capacity, cycle)
Description:
Removes arc (p,q), updates t, updates flows, where (k,l) is
the entering arc.
Input:
t: tree solution to be updated.
p: tail of the leaving arc.
q: head of the le... | 2.314235 | 1.695645 | 1.364811 |
'''
API:
simplex_select_entering_arc(self, t, pivot)
Description:
Decides and returns entering arc using pivot rule.
Input:
t: current spanning tree solution
pivot: May be one of the following; 'first_eligible' or 'dantzig'.
'da... | def simplex_select_entering_arc(self, t, pivot) | API:
simplex_select_entering_arc(self, t, pivot)
Description:
Decides and returns entering arc using pivot rule.
Input:
t: current spanning tree solution
pivot: May be one of the following; 'first_eligible' or 'dantzig'.
'dantzig' is the defaul... | 2.44073 | 1.76473 | 1.383062 |
'''
API:
simplex_optimal(self, t)
Description:
Checks if the current solution is optimal, if yes returns True,
False otherwise.
Pre:
'flow' attributes represents a solution.
Input:
t: Graph instance tat reperesents spann... | def simplex_optimal(self, t) | API:
simplex_optimal(self, t)
Description:
Checks if the current solution is optimal, if yes returns True,
False otherwise.
Pre:
'flow' attributes represents a solution.
Input:
t: Graph instance tat reperesents spanning tree solution.
... | 4.381153 | 2.062686 | 2.124004 |
'''
API:
simplex_find_tree(self)
Description:
Assumes a feasible flow solution stored in 'flow' attribute's of
arcs and converts this solution to a feasible spanning tree
solution.
Pre:
(1) 'flow' attributes represents a feasibl... | def simplex_find_tree(self) | API:
simplex_find_tree(self)
Description:
Assumes a feasible flow solution stored in 'flow' attribute's of
arcs and converts this solution to a feasible spanning tree
solution.
Pre:
(1) 'flow' attributes represents a feasible flow solution.
... | 3.669038 | 2.118376 | 1.732005 |
'''
API:
simplex_connect(self, solution_g)
Description:
At this point we assume that the solution does not have a cycle.
We check if all the nodes are connected, if not we add an arc to
solution_g that does not create a cycle and return True. Other... | def simplex_connect(self, solution_g) | API:
simplex_connect(self, solution_g)
Description:
At this point we assume that the solution does not have a cycle.
We check if all the nodes are connected, if not we add an arc to
solution_g that does not create a cycle and return True. Otherwise
we ... | 4.740747 | 2.002278 | 2.367677 |
'''
API:
simplex_search(self, source, component_nr)
Description:
Searches graph starting from source. Its difference from usual
search is we can also go backwards along an arc. When the graph
is a spanning tree it computes predecessor, thread and d... | def simplex_search(self, source, component_nr) | API:
simplex_search(self, source, component_nr)
Description:
Searches graph starting from source. Its difference from usual
search is we can also go backwards along an arc. When the graph
is a spanning tree it computes predecessor, thread and depth
ind... | 3.435517 | 1.532596 | 2.241633 |
'''
API:
simplex_augment_cycle(self, cycle)
Description:
Augments along the cycle to break it.
Pre:
'flow', 'capacity' attributes on arcs.
Input:
cycle: list representing a cycle in the solution
Post:
'flow' attr... | def simplex_augment_cycle(self, cycle) | API:
simplex_augment_cycle(self, cycle)
Description:
Augments along the cycle to break it.
Pre:
'flow', 'capacity' attributes on arcs.
Input:
cycle: list representing a cycle in the solution
Post:
'flow' attribute will be modifi... | 3.375979 | 2.144258 | 1.574428 |
'''
API:
simplex_find_cycle(self)
Description:
Returns a cycle (list of nodes) if the graph has one, returns None
otherwise. Uses DFS. During DFS checks existence of arcs to lower
depth regions. Note that direction of the arcs are not important.
... | def simplex_find_cycle(self) | API:
simplex_find_cycle(self)
Description:
Returns a cycle (list of nodes) if the graph has one, returns None
otherwise. Uses DFS. During DFS checks existence of arcs to lower
depth regions. Note that direction of the arcs are not important.
Return:
... | 3.037843 | 2.151055 | 1.412257 |
'''
API:
get_simplex_solution_graph(self):
Description:
Assumes a feasible flow solution stored in 'flow' attribute's of
arcs. Returns the graph with arcs that have flow between 0 and
capacity.
Pre:
(1) 'flow' attribute represen... | def get_simplex_solution_graph(self) | API:
get_simplex_solution_graph(self):
Description:
Assumes a feasible flow solution stored in 'flow' attribute's of
arcs. Returns the graph with arcs that have flow between 0 and
capacity.
Pre:
(1) 'flow' attribute represents a feasible flow s... | 5.174533 | 1.828176 | 2.830435 |
'''
API:
simplex_compute_potentials(self, t, root)
Description:
Computes node potentials for a minimum cost flow problem and stores
them as node attribute 'potential'. Based on pseudocode given in
Network Flows by Ahuja et al.
Pre:
... | def simplex_compute_potentials(self, t, root) | API:
simplex_compute_potentials(self, t, root)
Description:
Computes node potentials for a minimum cost flow problem and stores
them as node attribute 'potential'. Based on pseudocode given in
Network Flows by Ahuja et al.
Pre:
(1) Assumes a di... | 3.70418 | 1.559001 | 2.375996 |
'''
API:
identify_cycle(self, t, k, l)
Description:
Identifies and returns to the pivot cycle, which is a list of
nodes.
Pre:
(1) t is spanning tree solution, (k,l) is the entering arc.
Input:
t: current spanning tree so... | def simplex_identify_cycle(self, t, k, l) | API:
identify_cycle(self, t, k, l)
Description:
Identifies and returns to the pivot cycle, which is a list of
nodes.
Pre:
(1) t is spanning tree solution, (k,l) is the entering arc.
Input:
t: current spanning tree solution
k... | 3.025113 | 1.777321 | 1.702063 |
'''
API:
page_rank(self, damping_factor=0.85, max_iterations=100,
min_delta=0.00001)
Description:
Compute and return the page-rank of a directed graph.
This function was originally taken from here and modified for this
graph class... | def page_rank(self, damping_factor=0.85, max_iterations=100,
min_delta=0.00001) | API:
page_rank(self, damping_factor=0.85, max_iterations=100,
min_delta=0.00001)
Description:
Compute and return the page-rank of a directed graph.
This function was originally taken from here and modified for this
graph class: http://code.google... | 3.527124 | 2.119827 | 1.663873 |
'''
API:
get_degree(self)
Description:
Returns degrees of nodes in dictionary format.
Return:
Returns a dictionary of node degrees. Keys are node names, values
are corresponding degrees.
'''
degree = {}
if self.attr[... | def get_degrees(self) | API:
get_degree(self)
Description:
Returns degrees of nodes in dictionary format.
Return:
Returns a dictionary of node degrees. Keys are node names, values
are corresponding degrees. | 3.422278 | 2.176366 | 1.572473 |
'''
API:
get_degree(self)
Description:
Returns degrees of nodes in dictionary format.
Return:
Returns a dictionary of node degrees. Keys are node names, values
are corresponding degrees.
'''
degree = {}
if self.attr[... | def get_in_degrees(self) | API:
get_degree(self)
Description:
Returns degrees of nodes in dictionary format.
Return:
Returns a dictionary of node degrees. Keys are node names, values
are corresponding degrees. | 5.065123 | 2.779783 | 1.822129 |
'''
API:
get_degree(self)
Description:
Returns degrees of nodes in dictionary format.
Return:
Returns a dictionary of node degrees. Keys are node names, values
are corresponding degrees.
'''
degree = {}
if self.attr[... | def get_out_degrees(self) | API:
get_degree(self)
Description:
Returns degrees of nodes in dictionary format.
Return:
Returns a dictionary of node degrees. Keys are node names, values
are corresponding degrees. | 5.106659 | 2.758742 | 1.851082 |
'''
API:
get_diameter(self)
Description:
Returns diameter of the graph. Diameter is defined as follows.
distance(n,m): shortest unweighted path from n to m
eccentricity(n) = $\max _m distance(n,m)$
diameter = $\min _n eccentricity(n) = ... | def get_diameter(self) | API:
get_diameter(self)
Description:
Returns diameter of the graph. Diameter is defined as follows.
distance(n,m): shortest unweighted path from n to m
eccentricity(n) = $\max _m distance(n,m)$
diameter = $\min _n eccentricity(n) = \min _n \max _m dist... | 3.943413 | 2.296654 | 1.717025 |
'''
API:
create_cluster(self, node_list, cluster_attrs, node_attrs)
Description:
Creates a cluster from the node given in the node list.
Input:
node_list: List of nodes in the cluster.
cluster_attrs: Dictionary of cluster attributes, see Do... | def create_cluster(self, node_list, cluster_attrs={}, node_attrs={}) | API:
create_cluster(self, node_list, cluster_attrs, node_attrs)
Description:
Creates a cluster from the node given in the node list.
Input:
node_list: List of nodes in the cluster.
cluster_attrs: Dictionary of cluster attributes, see Dot language
... | 3.389122 | 1.783896 | 1.899843 |
'''
API:
add(self, aList)
Description:
Adds items in the list to the set.
Input:
aList: List of items.
Post:
self.sizes will be updated.
'''
self.add_node(aList[0])
for i in range(1, len(aList)):
... | def add(self, aList) | API:
add(self, aList)
Description:
Adds items in the list to the set.
Input:
aList: List of items.
Post:
self.sizes will be updated. | 3.49029 | 1.94994 | 1.789947 |
'''
API:
union(self, i, j):
Description:
Finds sets of i and j and unites them.
Input:
i: Item.
j: Item.
Post:
self.sizes will be updated.
'''
roots = (self.find(i), self.find(j))
if roots[0] == r... | def union(self, i, j) | API:
union(self, i, j):
Description:
Finds sets of i and j and unites them.
Input:
i: Item.
j: Item.
Post:
self.sizes will be updated. | 2.799084 | 1.881919 | 1.487357 |
'''
API:
find(self, i)
Description:
Returns root of set that has i.
Input:
i: Item.
Return:
Returns root of set that has i.
'''
current = i
edge_list = []
while len(self.get_neighbors(current)) != 0:
... | def find(self, i) | API:
find(self, i)
Description:
Returns root of set that has i.
Input:
i: Item.
Return:
Returns root of set that has i. | 3.590603 | 2.413647 | 1.487626 |
return self._eval(XPathContext(node, node, 1, 1)) | def evaluate(self, node: InstanceNode) -> XPathValue | Evaluate the receiver and return the result.
Args:
node: Context node for XPath evaluation.
Raises:
XPathTypeError: If a subexpression of the receiver is of a wrong
type. | 13.745796 | 22.322382 | 0.615785 |
if isinstance(raw, str):
return raw | def from_raw(self, raw: RawScalar) -> Optional[ScalarValue] | Return a cooked value of the receiver type.
Args:
raw: Raw value obtained from JSON parser. | 10.492768 | 18.917692 | 0.554654 |
res = self.parse_value(text)
if res is None:
raise InvalidArgument(text)
return res | def from_yang(self, text: str) -> ScalarValue | Parse value specified in a YANG module.
Args:
text: String representation of the value.
Raises:
InvalidArgument: If the receiver type cannot parse the text. | 5.595641 | 4.983489 | 1.122836 |
self._handle_restrictions(stmt, sctx) | def _handle_properties(self, stmt: Statement, sctx: SchemaContext) -> None | Handle type substatements. | 17.458361 | 7.756172 | 2.250899 |
res = {"base": self.yang_type()}
if self.name is not None:
res["derived"] = self.name
return res | def _type_digest(self, config: bool) -> Dict[str, Any] | Return receiver's type digest.
Args:
config: Specifies whether the type is on a configuration node. | 8.045589 | 8.587066 | 0.936943 |
return sorted(self.bit.items(), key=lambda x: x[1]) | def sorted_bits(self) -> List[Tuple[str, int]] | Return list of bit items sorted by position. | 4.237206 | 3.203303 | 1.322762 |
res = 0
try:
for b in val:
res += 1 << self.bit[b]
except KeyError:
return None
return res | def as_int(self, val: Tuple[str]) -> int | Transform a "bits" value to an integer. | 5.627318 | 3.764819 | 1.494711 |
nextpos = 0
for bst in stmt.find_all("bit"):
if not sctx.schema_data.if_features(bst, sctx.text_mid):
continue
label = bst.argument
pst = bst.find1("position")
if pst:
pos = int(pst.argument)
self.bi... | def _handle_properties(self, stmt: Statement, sctx: SchemaContext) -> None | Handle **bit** statements. | 7.340478 | 6.331617 | 1.159337 |
if isinstance(raw, bool):
return raw | def from_raw(self, raw: RawScalar) -> Optional[bool] | Override superclass method. | 6.273602 | 4.553787 | 1.377667 |
if text == "true":
return True
if text == "false":
return False | def parse_value(self, text: str) -> Optional[bool] | Parse boolean value.
Args:
text: String representation of the value. | 3.321363 | 4.075699 | 0.814919 |
try:
return base64.b64decode(raw, validate=True)
except TypeError:
return None | def from_raw(self, raw: RawScalar) -> Optional[bytes] | Override superclass method. | 3.307441 | 2.741544 | 1.206415 |
return sorted(self.enum.items(), key=lambda x: x[1]) | def sorted_enums(self) -> List[Tuple[str, int]] | Return list of enum items sorted by value. | 3.67024 | 2.911671 | 1.260527 |
nextval = 0
for est in stmt.find_all("enum"):
if not sctx.schema_data.if_features(est, sctx.text_mid):
continue
label = est.argument
vst = est.find1("value")
if vst:
val = int(vst.argument)
self.enum... | def _handle_properties(self, stmt: Statement, sctx: SchemaContext) -> None | Handle **enum** statements. | 7.63625 | 6.737953 | 1.133319 |
try:
return self.sctx.schema_data.translate_pname(text, self.sctx.text_mid)
except (ModuleNotRegistered, UnknownPrefix):
raise InvalidArgument(text) | def from_yang(self, text: str) -> Optional[QualName] | Override the superclass method. | 16.114906 | 15.44601 | 1.043305 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.