Skip to content

Commit

Permalink
Option to include all immediate edges of the core node(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
thvitt committed Mar 26, 2019
1 parent 5ea3795 commit 3262a7d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 3 additions & 1 deletion graphviewer/graphviewer.py
Expand Up @@ -36,9 +36,11 @@ def prepare_agraph():
extra = parse_nodes(request.args.get('extra', ''))
induced_edges = request.args.get('induced_edges', False)
ignored_edges = request.args.get('ignored_edges', False)
direct_assertions = request.args.get('assertions', False)
tred = request.args.get('tred', False)
if nodes:
g = info.subgraph(*nodes, context=context, abs_dates=abs_dates, pathes=extra, keep_timeline=True)
g = info.subgraph(*nodes, context=context, abs_dates=abs_dates, pathes=extra, keep_timeline=True,
direct_assertions=direct_assertions)
if induced_edges:
g = info.base.subgraph(g.nodes).copy()
if not ignored_edges or tred:
Expand Down
3 changes: 2 additions & 1 deletion graphviewer/templates/form.html
Expand Up @@ -16,9 +16,10 @@

<form method="get">
<p><label for="nodes">Zentrale(r) Knoten: </label><input type="text" name="nodes" id="nodes" value="{{ nodes }}" placeholder="2 V H.13"></p>
<h3>Kontextknoten:</h3>
<h3>Kontext:</h3>
<p><input type="checkbox" name="context" id="context" {% if context %}checked{% endif %}> <label for="context">Nachbarknoten</label></p>
<p><input type="checkbox" name="abs_dates" id="abs_dates" {% if abs_dates %}checked{% endif %}> <label for="abs_dates">absolute Datierungen rechtfertigen</label></p>
<p><input type="checkbox" name="assertions" id="assertions" {% if assertions %}checked{% endif %} <label for="assertions">unmittelbare Aussagen über Kernknoten</label> </p>
<p><label for="extra">Pfade von/zu (falls verfügbar): </label>
<input type="text" name="extra" id="extra" value="{{ extra }}" placeholder="A, 2 H"></p>
<h3>Kantenauswahl und -Gestaltung:</h3>
Expand Down
6 changes: 5 additions & 1 deletion src/macrogen/graph.py
Expand Up @@ -385,7 +385,7 @@ def add_path(self, graph: nx.MultiDiGraph, source: Node, target: Node, weight='i
raise e

def subgraph(self, *nodes: Node, context: bool = True, path_to: Iterable[Node] = {}, abs_dates: bool=True,
path_from: Iterable[Node] = {}, pathes: Iterable[Node] = {}, keep_timeline=False) -> nx.MultiDiGraph:
path_from: Iterable[Node] = {}, pathes: Iterable[Node] = {}, keep_timeline=False, direct_assertions: bool = False) -> nx.MultiDiGraph:
"""
Extracts a sensible subgraph from the base graph.
Expand Down Expand Up @@ -436,6 +436,10 @@ def subgraph(self, *nodes: Node, context: bool = True, path_to: Iterable[Node] =
for target in targets:
self.add_path(subgraph, node, target)

if direct_assertions:
subgraph.add_edges_from(self.base.in_edges(node, keys=True, data=True))
subgraph.add_edges_from(self.base.out_edges(node, keys=True, data=True))

if not keep_timeline:
subgraph = simplify_timeline(subgraph)

Expand Down

0 comments on commit 3262a7d

Please sign in to comment.