-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #580 from graphistry/dev/comm_layout
Dev/comm layout
- Loading branch information
Showing
15 changed files
with
441 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
210 changes: 210 additions & 0 deletions
210
demos/more_examples/graphistry_features/layout_modularity_weighted.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,210 @@ | ||
{ | ||
"nbformat": 4, | ||
"nbformat_minor": 0, | ||
"metadata": { | ||
"colab": { | ||
"provenance": [] | ||
}, | ||
"kernelspec": { | ||
"name": "python3", | ||
"display_name": "Python 3" | ||
}, | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"source": [ | ||
"### Modularity weighted layout\n", | ||
"\n", | ||
"When community labels are known, modularity weighting helps force the layout to better hightlight the community structure. The layout algorithm will weight edges based on whether they are same-community vs cross-community. If no community labels are provided, default to using Louivain." | ||
], | ||
"metadata": { | ||
"id": "UEQyPUiIK6VS" | ||
} | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/" | ||
}, | ||
"id": "Z9i0f7MrH4V9", | ||
"outputId": "5aa22d94-64e1-4bed-a579-e5333c0c19aa" | ||
}, | ||
"outputs": [ | ||
{ | ||
"output_type": "stream", | ||
"name": "stdout", | ||
"text": [ | ||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m75.0/75.0 kB\u001b[0m \u001b[31m2.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | ||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m263.0/263.0 kB\u001b[0m \u001b[31m9.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | ||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.1/3.1 MB\u001b[0m \u001b[31m28.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | ||
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m332.3/332.3 kB\u001b[0m \u001b[31m8.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", | ||
"\u001b[?25h" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"! pip install -q graphistry igraph" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"import graphistry\n", | ||
"import pandas as pd\n", | ||
"graphistry.register(api=3, username=FILL_ME_IN, password=FILL_ME_IN)" | ||
], | ||
"metadata": { | ||
"id": "Nk2xIrpUH5ud" | ||
}, | ||
"execution_count": 24, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"df = pd.read_csv('https://raw.githubusercontent.com/graphistry/pygraphistry/master/demos/data/transactions.csv')\n", | ||
"g = graphistry.edges(df, 'Destination', 'Source')" | ||
], | ||
"metadata": { | ||
"id": "LWZoFxJ2IYMS" | ||
}, | ||
"execution_count": 4, | ||
"outputs": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"# Before\n", | ||
"g.compute_igraph('community_multilevel', directed=False).plot()" | ||
], | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/", | ||
"height": 561 | ||
}, | ||
"id": "ffGGHcs_KPKH", | ||
"outputId": "769c30cc-99cd-4f43-d059-06ade9446c8d" | ||
}, | ||
"execution_count": 27, | ||
"outputs": [ | ||
{ | ||
"output_type": "stream", | ||
"name": "stderr", | ||
"text": [ | ||
"WARNING:graphistry.plugins.igraph:edge index g._edge not set so using edge index as ID; set g._edge via g.edges(), or change merge_if_existing to FalseWARNING:graphistry.plugins.igraph:edge index g._edge __edge_index__ missing as attribute in ig; using ig edge order for IDs" | ||
] | ||
}, | ||
{ | ||
"output_type": "execute_result", | ||
"data": { | ||
"text/plain": [ | ||
"<IPython.core.display.HTML object>" | ||
], | ||
"text/html": [ | ||
"\n", | ||
" <iframe id=\"582bf801-1b1e-489a-82f6-ab125dfac968\" src=\"https://hub.graphistry.com/graph/graph.html?dataset=0d6a30dfaa094e8a8b328615444dfd95&type=arrow&viztoken=4d1bfb2c-ca98-4d37-868e-43529b4146c6&usertag=7b512218-pygraphistry-0.34.2&splashAfter=1722670549&info=true\"\n", | ||
" allowfullscreen=\"true\" webkitallowfullscreen=\"true\" mozallowfullscreen=\"true\"\n", | ||
" oallowfullscreen=\"true\" msallowfullscreen=\"true\"\n", | ||
" style=\"width:100%; height:500px; border: 1px solid #DDD; overflow: hidden\"\n", | ||
" \n", | ||
" >\n", | ||
" </iframe>\n", | ||
" \n", | ||
" <script>\n", | ||
" try {\n", | ||
" $(\"#582bf801-1b1e-489a-82f6-ab125dfac968\").bind('mousewheel', function(e) { e.preventDefault(); });\n", | ||
" } catch (e) { console.error('exn catching scroll', e); }\n", | ||
" </script>\n", | ||
" " | ||
] | ||
}, | ||
"metadata": {}, | ||
"execution_count": 27 | ||
} | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"# After\n", | ||
"g2 = g.modularity_weighted_layout(g)" | ||
], | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/" | ||
}, | ||
"id": "ltw6qybCi0xA", | ||
"outputId": "ef5ea3ea-5b3d-429e-c979-ce13ea80797f" | ||
}, | ||
"execution_count": 19, | ||
"outputs": [ | ||
{ | ||
"output_type": "stream", | ||
"name": "stderr", | ||
"text": [ | ||
"WARNING:graphistry.plugins.igraph:edge index g._edge not set so using edge index as ID; set g._edge via g.edges(), or change merge_if_existing to FalseWARNING:graphistry.plugins.igraph:edge index g._edge __edge_index__ missing as attribute in ig; using ig edge order for IDs" | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [ | ||
"g2.plot()" | ||
], | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/", | ||
"height": 543 | ||
}, | ||
"id": "rqBkXQDWdOE7", | ||
"outputId": "f2eee36e-ddd5-4d21-fcec-32761476aa55" | ||
}, | ||
"execution_count": 21, | ||
"outputs": [ | ||
{ | ||
"output_type": "execute_result", | ||
"data": { | ||
"text/plain": [ | ||
"<IPython.core.display.HTML object>" | ||
], | ||
"text/html": [ | ||
"\n", | ||
" <iframe id=\"afae5f89-0caf-4aa5-b1af-b5dabdd43e79\" src=\"https://hub.graphistry.com/graph/graph.html?dataset=e64d74fbd26541169ac8b670ed57a19a&type=arrow&viztoken=5e9461fa-ad1d-4ccd-8632-43f15e379f62&usertag=7b512218-pygraphistry-0.34.2&splashAfter=1722667198&info=true&edgeInfluence=2.0\"\n", | ||
" allowfullscreen=\"true\" webkitallowfullscreen=\"true\" mozallowfullscreen=\"true\"\n", | ||
" oallowfullscreen=\"true\" msallowfullscreen=\"true\"\n", | ||
" style=\"width:100%; height:500px; border: 1px solid #DDD; overflow: hidden\"\n", | ||
" \n", | ||
" >\n", | ||
" </iframe>\n", | ||
" \n", | ||
" <script>\n", | ||
" try {\n", | ||
" $(\"#afae5f89-0caf-4aa5-b1af-b5dabdd43e79\").bind('mousewheel', function(e) { e.preventDefault(); });\n", | ||
" } catch (e) { console.error('exn catching scroll', e); }\n", | ||
" </script>\n", | ||
" " | ||
] | ||
}, | ||
"metadata": {}, | ||
"execution_count": 21 | ||
} | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"source": [], | ||
"metadata": { | ||
"id": "oFTINwvZfsuH" | ||
}, | ||
"execution_count": null, | ||
"outputs": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
#!/bin/bash | ||
set -ex | ||
|
||
# Alias for docker-compose | ||
# Alias for docker compose | ||
|
||
COMPOSE_DOCKER_CLI_BUILD=1 \ | ||
DOCKER_BUILDKIT=1 \ | ||
docker-compose $@ | ||
docker compose $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
version: "3.5" | ||
|
||
networks: | ||
grph_net: | ||
name: grph_net | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
:orphan: | ||
|
||
.. ^ FIXME | ||
graphistry.layout.modularity_weighted package | ||
============================================= | ||
|
||
Submodules | ||
---------- | ||
|
||
Module contents | ||
--------------- | ||
|
||
.. automodule:: graphistry.layout.modularity_weighted | ||
:members: | ||
:undoc-members: | ||
:show-inheritance: | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#from .utils import * | ||
#from .graph import * | ||
from .gib import group_in_a_box_layout | ||
from .sugiyama import SugiyamaLayout | ||
from .modularity_weighted import modularity_weighted_layout | ||
from .ring import time_ring, ring_categorical, ring_continuous | ||
from .sugiyama import SugiyamaLayout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .modularity_weighted import modularity_weighted_layout |
Oops, something went wrong.