Skip to content

Commit

Permalink
fix issue with parsing explicit edge lists for edge group definition;…
Browse files Browse the repository at this point in the history
… now brackets must be used rather than parentheses to define edges
  • Loading branch information
Andras Szilagyi committed Jul 3, 2024
1 parent 0b56c4c commit 87746b5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions docs/configfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ title: Tabnetviz configuration options
An arbitrary number of further node groups can be defined. When a group is defined, it is added to the node table as a Boolean column so it can be used in the definition of subsequent groups. For this reason, node group names cannot be identical to existing node table column names.
* **edgegroups:**\
Groups of edges can be defined; optional.
* _**groupname: columnexpression**_ | **[(_source1, target1_), (_source2, target2_), ...]**\
Edge group name and a Boolean expression to define the edge group, or an explicit edge list. The expression can use edge table column names and simple numerical or string operations on them. Examples: `myedgegroup1: abs(c) > 3`, `myedgegroup2: interaction.str.lower() >= 'p'`. Edges can also be explicitly listed by listing **(_source, target_)** pairs, e.g. `[(node1, node23), (node45, node57)]`
* _**groupname: columnexpression**_ | **[(_source1, target1_), (_source2, target2_), ...]**\
* _**groupname: columnexpression**_ | **[[_source1, target1_], [_source2, target2_], ...]**\
Edge group name and a Boolean expression to define the edge group, or an explicit edge list. The expression can use edge table column names and simple numerical or string operations on them. Examples: `myedgegroup1: abs(c) > 3`, `myedgegroup2: interaction.str.lower() >= 'p'`. Edges can also be explicitly listed by listing **[_source, target_]** pairs, e.g. `[[node1, node23], [node45, node57]]`
* _**groupname: columnexpression**_ | **[[_source1, target1_], [_source2, target2_], ...]**\
An arbitrary number of further edge groups can be defined. When a group is defined, it is added to the edge table as a Boolean column so it can be used in the definition of subsequent groups. For this reason, edge group names cannot be identical to existing edge table column names.
* **clusters:** **_nodegroup1_** | **[_nodegroup1, nodegroup2, ..._]**\
Define clusters as node groups (simple form without style specifications). Node groups should be listed in brackets (which can be omitted if there is only one cluster). The **dot** and **fdp** layout algorithms will draw a box around the nodes belonging to a cluster. Only node groups defined above under the **nodegroups** keyword can be used. If you simply list the node groups corresponding to clusters, they will be drawn with the default cluster styles. Otherwise, you can specify styles for each cluster, see below.
Expand Down
4 changes: 2 additions & 2 deletions docs/userguide.md
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ Boolean table column defining the group than to list it in the
tabnetviz configuration file. A node list is a comma-separated list of
node names (space after the comma is necessary!) in square brackets:
`[node1, node23, node57]`. An edge list is specified by providing a
list of **(source, target)** pairs, e.g `[(node1, node3), (node5,
node7), (node8, node13)]`.
list of **[source, target]** pairs, e.g `[[node1, node3], [node5,
node7], [node8, node13]]`.

Groups are added to the node/edge table as new Boolean columns. As
group definitions are processed in the order they appear in the
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name='tabnetviz',
version='1.2',
version='1.3',
description='Table-based network visualizer',
long_description=README,
long_description_content_type='text/markdown',
Expand Down
4 changes: 2 additions & 2 deletions tabnetviz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
# See https://www.gnu.org/licenses/gpl-3.0.html

__author__ = "Andras Szilagyi"
__copyright__ = "Copyright 2023 Andras Szilagyi"
__copyright__ = "Copyright 2024 Andras Szilagyi"
__license__ = "GPLv3"
__version__ = "1.2"
__version__ = "1.3"
__maintainer__ = "Andras Szilagyi"
__email__ = "[email protected]"
__status__ = "Production"
2 changes: 1 addition & 1 deletion tabnetviz/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def table2net(args):
edgetab[egname] = edgetab.eval(groupdef, engine='python')
elif type(groupdef) == list: # explicit edge list given
edges = list(zip(edgetab[sourcecolumn], edgetab[targetcolumn]))
ES = set(groupdef)
ES = set(tuple(e) for e in groupdef)
U = ES-set(edges)
if U: # there are unknown edges given
raise ValueError('unknown edges specified in edge group definition: '+str(U))
Expand Down
2 changes: 2 additions & 0 deletions tabnetviz/configtemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@
nodegroups: # optional; define node groups using boolean queries
group1: expr1 # node group name: boolean expression with node table column names
group2: expr2
group3: [node1, node2, node3] # explicit node list
#
# Define edge groups
#
edgegroups: # optional; define edge groups using boolean queries
group1: expr1 # edge group name: expression with edge table column names as query
group2: expr2
group3: [[node1, node2], [node3, node4]] # explicit edge list
#
# Define clusters (note: layout must be dot or fdp)
# (clusters are node groups with a box drawn around them)
Expand Down

0 comments on commit 87746b5

Please sign in to comment.