Commit ea30207c authored by Andrew's avatar Andrew
Browse files

Updated documentation. Readme now rendered correctly as markdown.

parent cfd188a1
......@@ -26,7 +26,7 @@ class TarjansAlgorithm:
Attributes
----------
g : Automata or igraph.Graph
The automaton or graph
The automaton or graph used in the algorithm
"""
def __init__(self, g):
"""
......@@ -35,7 +35,7 @@ class TarjansAlgorithm:
Parameters
----------
g : Automata or igraph.Graph
The automaton or graph
The automaton or graph used in the algorithm
"""
self.g = g
self._result = list()
......@@ -71,10 +71,10 @@ class TarjansAlgorithm:
id_dict = dict(zip(DFS_vertices, order))
for i in range(0, self._size):
if self._disc[i] == -1:
self.scc_util(i, time, id_dict, DFS_vertices)
self._scc_util(i, time, id_dict, DFS_vertices)
return self._result
def scc_util(self, i, time, id_dict, DFS_vertices):
def _scc_util(self, i, time, id_dict, DFS_vertices):
self._disc[i] = time
self._low[i] = time
time += 1
......@@ -87,7 +87,7 @@ class TarjansAlgorithm:
else:
for v in DFS_vertices[i].successors():
if self._disc[id_dict.get(v, -1)] == -1:
self.scc_util(id_dict.get(v), time, id_dict, DFS_vertices)
self._scc_util(id_dict.get(v), time, id_dict, DFS_vertices)
self._low[i] = min(self._low[i], self._low[id_dict.get(v)])
elif self._OnStack[id_dict.get(v)] == True:
self._low[i] = min(self._low[i], self._disc[id_dict.get(v)])
......@@ -100,6 +100,7 @@ class TarjansAlgorithm:
self._OnStack[w] = False
self._result.append(scc)
# TODO - rename
def DFS(self, initial) -> list:
"""
Depth first search algorithm that returns
......@@ -130,6 +131,7 @@ class TarjansAlgorithm:
if neighbor not in visited:
self._DFSUtil(neighbor, visited, d)
class JohnsonsAlgorithm:
"""
Computes johnson's algorithm, returns a list of
......
......@@ -16,31 +16,30 @@ def product_NFA(g_list, save_state_names=True, save_marked_states=True, priority
the resulting composition as an automata.
Parameters
g_list: an iterable collection of Automata (class object) for which
----------
g_list: Iterable[Automata]
An iterable collection of Automata (class object) for which
the parallel composition will be computed. If saving state names,
this should be ordered, as it determines the order that vertex indices
are stored in the composition's vertex names. MUST have at least two
graphs (length > 1).
g_comp: directed igraph Graph, assumed to be empty. Used to store the output
instead of returning a copy. This is different from the interface in the
Automata class file, which returns a copy of the result of the
composition.
save_state_names (default True): whether vertex names should be saved
in the igraph Graph "name" attribute. If set to false, the attribute
will not be set (less memory usage). Vertex names are a list of indicies
from each input, in the order used by 'inputs'. For example, in the operation
A || B || C, a vertex name '(0,3,1)' in the output O means that state is
save_state_names: bool
If True, then vertex names are saved in the igraph Graph "name" attribute.
If set to false, the attribute will not be set (less memory usage).
Vertex names are a list of indicies from each input, in the order used by 'inputs'.
For example, in the operation A || B || C, a vertex name '(0,3,1)' in the output O means that state is
composed of vertex 0 in A, 3 in B, and 1 in C (by index, NOT vertex name).
save_marked_states (default False): whether states in the composition
should be 'marked' or not (marked if the composed states are both marked).
(Default value: True)
save_marked_states : bool
If True, then states in the composition are 'marked' (marked if all the composed states are marked).
An error will be raised if this parameter is True, but not all Automata
in the composition have the "marked" parameter on their vertices.
(Default value: True)
Doesn't return anything to avoid potentially making redundant copies.
Returns
-------
NFA
The product of the automata
"""
g_comp = NFA()
......@@ -108,7 +107,7 @@ def product_NFA(g_list, save_state_names=True, save_marked_states=True, priority
init.append(True)
if save_marked_states:
g_comp_vert_mark.append(marked_bool(g1, g2, (v1, v2)))
g_comp_vert_mark.append(_marked_bool(g1, g2, (v1, v2)))
# set next_states_to_check returns False when empty
while next_states_to_check:
......@@ -150,7 +149,7 @@ def product_NFA(g_list, save_state_names=True, save_marked_states=True, priority
# maybe only do this with a flag passed into fn?
if save_marked_states:
g_comp_vert_mark.append(
marked_bool(g1, g2, new_vert_pair)
_marked_bool(g1, g2, new_vert_pair)
)
# need to check the new states' neighbors
next_states_temp.add(new_vert_pair)
......@@ -160,7 +159,7 @@ def product_NFA(g_list, save_state_names=True, save_marked_states=True, priority
next_states_to_check = next_states_temp
assemble_graph(
_assemble_graph(
g_comp,
g_comp_edges,
index - 1, # -1 to undo the increment after the last added vertex
......@@ -178,7 +177,7 @@ def product_NFA(g_list, save_state_names=True, save_marked_states=True, priority
return g_comp
def assemble_graph(
def _assemble_graph(
output,
output_edges,
index,
......@@ -220,7 +219,7 @@ def assemble_graph(
output.vs["out"] = adj
def marked_bool(g1, g2, vert_pair):
def _marked_bool(g1, g2, vert_pair):
"""
graphs g1,g2
vert_pair (v1, v2) vertices in g1,g2
......
......@@ -5,4 +5,5 @@ DESops API
:maxdepth: 3
api/DESops.automata
api/DESops.basic_operations
api/DESops.opacity
......@@ -33,8 +33,10 @@ release = version
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc', 'sphinx.ext.napoleon'
'sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'm2r2'
]
source_suffix = ['.rst', '.md']
# TODO <awintenb@umich.edu> images from markdown (as in readme) not rendered correctly in documentation
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
......
Readme
===================================
.. include:: ../../README.md
.. mdinclude:: ../../README.md
......@@ -301,6 +301,18 @@ MarkupSafe = ">=2.0"
[package.extras]
i18n = ["Babel (>=2.7)"]
[[package]]
name = "m2r2"
version = "0.3.2"
description = "Markdown and reStructuredText in a single file."
category = "main"
optional = true
python-versions = "*"
[package.dependencies]
docutils = "*"
mistune = "0.8.4"
[[package]]
name = "markupsafe"
version = "2.1.1"
......@@ -317,6 +329,14 @@ category = "dev"
optional = false
python-versions = "*"
[[package]]
name = "mistune"
version = "0.8.4"
description = "The fastest markdown parser in pure Python"
category = "main"
optional = true
python-versions = "*"
[[package]]
name = "more-itertools"
version = "8.13.0"
......@@ -851,13 +871,13 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-
[extras]
caching = ["pycairo"]
docs = ["Sphinx", "sphinx-rtd-theme", "pyment"]
docs = ["Sphinx", "sphinx-rtd-theme", "pyment", "m2r2"]
opacity_enf = []
[metadata]
lock-version = "1.1"
python-versions = "^3.7"
content-hash = "b340c0dfc6157987e19cb83076e756d695dd253d0633022dfc4a2f644a498537"
content-hash = "876fb7e4df17e30964f3c1a053ce89d1eae0c60537a5ca6663ff0d8eae97d249"
[metadata.files]
alabaster = [
......@@ -1028,6 +1048,10 @@ jinja2 = [
{file = "Jinja2-3.1.2-py3-none-any.whl", hash = "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"},
{file = "Jinja2-3.1.2.tar.gz", hash = "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"},
]
m2r2 = [
{file = "m2r2-0.3.2-py3-none-any.whl", hash = "sha256:d3684086b61b4bebe2307f15189495360f05a123c9bda2a66462649b7ca236aa"},
{file = "m2r2-0.3.2.tar.gz", hash = "sha256:ccd95b052dcd1ac7442ecb3111262b2001c10e4119b459c34c93ac7a5c2c7868"},
]
markupsafe = [
{file = "MarkupSafe-2.1.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:86b1f75c4e7c2ac2ccdaec2b9022845dbb81880ca318bb7a0a01fbf7813e3812"},
{file = "MarkupSafe-2.1.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f121a1420d4e173a5d96e47e9a0c0dcff965afdf1626d28de1460815f7c4ee7a"},
......@@ -1074,6 +1098,10 @@ mccabe = [
{file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"},
{file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"},
]
mistune = [
{file = "mistune-0.8.4-py2.py3-none-any.whl", hash = "sha256:88a1051873018da288eee8538d476dffe1262495144b33ecb586c4ab266bb8d4"},
{file = "mistune-0.8.4.tar.gz", hash = "sha256:59a3429db53c50b5c6bcc8a07f8848cb00d7dc8bdb431a4ab41920d201d4756e"},
]
more-itertools = [
{file = "more-itertools-8.13.0.tar.gz", hash = "sha256:a42901a0a5b169d925f6f217cd5a190e32ef54360905b9c39ee7db5313bfec0f"},
{file = "more_itertools-8.13.0-py3-none-any.whl", hash = "sha256:c5122bffc5f104d37c1626b8615b511f3427aa5389b94d61e5ef8236bfbc3ddb"},
......
......@@ -19,6 +19,7 @@ colorama = {version = "^0.4.3", platform = "windows"}
Sphinx = {version="^5.0", optional=true}
sphinx-rtd-theme = {version="^1.0.0", optional=true}
m2r2 = {version="^0.3.2", optional=true}
pyment = {version="^0.3.3", optional=true}
......@@ -47,4 +48,4 @@ build-backend = "poetry.masonry.api"
[tool.poetry.extras]
caching = ["pycairo"]
opacity_enf = ["edisyn"]
docs = ["Sphinx", "sphinx-rtd-theme", "pyment"]
docs = ["Sphinx", "sphinx-rtd-theme", "pyment", "m2r2"]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment