plexsim.utils package¶
Submodules¶
plexsim.utils.annealing module¶
- plexsim.utils.annealing.annealing(m, theta=0.1, rate=0.01, reset=True, verbose=False)¶
- plexsim.utils.annealing.cooling(x, k, rate)¶
plexsim.utils.graph module¶
- class plexsim.utils.graph.ConnectedSimpleGraphs¶
Bases:
object
- generate(n)¶
- rvs(n, sparseness=None)¶
Generate random connected graph of size n
- plexsim.utils.graph.Willson(n: int, m: Optional[int] = None) → <networkx.classes.graph.Graph object at 0x7fbf74d04160>¶
- plexsim.utils.graph.Willson_matrix(n: int)¶
- plexsim.utils.graph.bfs_iso(graph, discovered, tree=<networkx.classes.digraph.DiGraph object>)¶
Breadth first search isomorphism algorithm. Constructs a directed tree-like graph from a node outwards
- plexsim.utils.graph.construct_iso_tree(nodes, graph)¶
- plexsim.utils.graph.extract_roles(node: int, g: networkx.classes.graph.Graph, roles: list) → list¶
- plexsim.utils.graph.get_neighbors(g, node)¶
- plexsim.utils.graph.jujujajaki(g, t, p1, p2, p3, w0=0.2, delta=0.1)¶
- plexsim.utils.graph.legacy_graph(graph)¶
- plexsim.utils.graph.make_connected(g) → networkx.classes.graph.Graph¶
- plexsim.utils.graph.nx_layout(graph, layout=None, **kwargs)¶
- plexsim.utils.graph.powerlaw_graph(n, gamma=1, connected=False, base=<class 'networkx.classes.graph.Graph'>)¶
- plexsim.utils.graph.recursive_tree(r, jump=0)¶
- plexsim.utils.graph.walk(root: int, g: networkx.classes.graph.Graph, visited: set) → tuple¶
- plexsim.utils.graph.walkm(root, g, visited)¶
plexsim.utils.hm module¶
- plexsim.utils.hm.construct_hm(patterns, m) → pandas.core.frame.DataFrame¶
- plexsim.utils.hm.gen_rvs_hm(m, k)¶
- plexsim.utils.hm.generate_hm(df)¶
- plexsim.utils.hm.sample_random_node(g)¶
plexsim.utils.rules module¶
- plexsim.utils.rules.check_df(queue, n, m, path=[], vp_path=[], results=[], verbose=False) → list¶
- Parameters
queue – edge queue, start with (node, node)
n – number of edges in the rule graph
m – model
path – monitors edges visited in social network
vp_path – monitors edges visited in value network
results – output. List of 2. First index contained completed value networks, second index contains branch options
verbose – print intermediate step for heavy debugging!
- plexsim.utils.rules.check_doubles(path, results) → None¶
Don’t allow for double edges Adds path inplace if it does not occur in results
- plexsim.utils.rules.check_endpoint(s, m, vp_path) → bool¶
Check if an end point is reached
- plexsim.utils.rules.create_rule_full(rule, connection_weight_other=- 1, connection_weight=1, self_weight=- 1) → networkx.classes.graph.Graph¶
Create a full rule graph
Multiplies weight * @connection_weight if the edge is non-zero Sets the weight to be @connection_weight_other if no edge is found.
- plexsim.utils.rules.merge(results, n) → None¶
Merge paths from branches inplace
plexsim.utils.visualisation module¶
- class plexsim.utils.visualisation.GraphAnimation(graph: object, time_data: dict, n=1, cmap=None)¶
Bases:
object
- add_bb(ax, bounds)¶
add boundings box
- static add_rule_graph(rules, ax, cmap)¶
- add_rule_igraph(rules, ax, cmap)¶
- animate(idx, edges=False)¶
- gen_panel(n_panels=3, **kwargs)¶
- setup(ax=None, layout=None, rules=None, bounds=None, node_kwargs={}, edge_kwargs={}, labels={}, use_timer=True)¶
- plexsim.utils.visualisation.create_grid_layout(g)¶
- plexsim.utils.visualisation.discrete_cmap(N, base_cmap=None)¶
Create an N-bin discrete colormap from the specified input map
- plexsim.utils.visualisation.simple_animate(graph, time_data, n, file='test.mp4')¶
I use this too often –> simple wrapper
- plexsim.utils.visualisation.turnoff_spines(ax)¶
- plexsim.utils.visualisation.vis_rules(m, ax, **kwargs)¶
Visualize value networks
- plexsim.utils.visualisation.visualize_graph(m, ax, pos=None, **kwargs)¶
Visualize value networks