Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xgi data docs page #496

Merged
merged 11 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/source/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,31 @@
margin-block-end: 0;
padding-inline-start: 0.5em;
}

table {
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
}

td, th {
border: 1px solid #ddd;
padding: 8px;
}

td a {
width: 100%;
display: block;
}

table tr:nth-child(even){background-color: #f2f2f2;}

table tr:hover {background-color: #ddd;}

th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #04AA6D;
color: white;
}
75 changes: 75 additions & 0 deletions docs/source/_static/table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
async function fetch_JSON_file(url) {
try {
const response = await fetch(url);

if (!response.ok) {
throw new Error(response);
}

const json_data = await response.json();
return json_data;
} catch (error) {
console.error('Error fetching JSON:', error);
}
}

function create_table(json_data) {
const body = document.body;
const section = document.getElementById("network-statistics")
const table = document.createElement('table');
const table_header = document.createElement('thead')
const table_body = document.createElement('tbody')

// Create header row
const header_row = document.createElement('tr');
const headers = ["Dataset", "|V|", "|E|", "|E<sub>unique</sub>|", "s<sub>max</sub>"]
const header_attrs = ["num-nodes", "num-edges", "num-unique-edges", "max-edge-size"]

for (const i in headers) {
const h = document.createElement('th');
h.innerHTML = headers[i];
header_row.appendChild(h)
}
table_header.appendChild(header_row)

// Create data rows
for (const key in json_data) {
const data_row = document.createElement('tr');

// dataset name
const td_name = document.createElement('td');
const url = json_data[key]["url"].split("/files")[0]
td_name.innerHTML = '<a href=' + url + '>' + key + '</a>';
data_row.appendChild(td_name);

for (const i in header_attrs){
const td = document.createElement('td');
const attr = header_attrs[i]
if (json_data[key][attr]) {
td.textContent = json_data[key][attr];
}
else {
td.textContent = "N/A"
}
data_row.appendChild(td);
}
table_body.appendChild(data_row);
}
table.appendChild(table_header)
table.appendChild(table_body)
console.log(table)
section.appendChild(table);
}

function display_table(){
url = 'https://raw.githubusercontent.com/xgi-org/xgi-data/main/index.json';
data = fetch_JSON_file(url)
.then(data => {
// Handle the JSON data
create_table(data);
})
.catch(error => {
// Handle errors
console.error('Error:', error);
});
}
3 changes: 1 addition & 2 deletions docs/source/api/tutorials/focus_tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@
Tutorial 4 - Generative_Models
Tutorial 5 - Plotting
Tutorial 6 - Statistics
Tutorial 7 - Convex hulls hypergraph plotting
Tutorial 8 - Directed Hypergraphs
Tutorial 7 - Directed Hypergraphs
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
html_css_files = ["custom.css"]
html_js_files = ["table.js"]

# If your documentation needs a minimal Sphinx version, state it here.
needs_sphinx = "1.3"
Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
about
contributors
higher-order
xgi-data
gallery
using-xgi

Expand Down
2 changes: 1 addition & 1 deletion docs/source/using-xgi.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Nicholas W. Landry and Juan Restrepo, "Opinion disparity in hypergraphs with com
:bdg-link-primary-line:`Paper <https://doi.org/10.1103/PhysRevE.108.034311>`
:bdg-link-primary-line:`Code <https://github.com/nwlandry/opinion-disparity-in-hypergraphs>`

Timothy LaRock and Renaud Lambiotte, "Encapsulation Structure and Dynamics in Hypergraphs", Journal of Physics: Complexity, In Press (2023).
Timothy LaRock and Renaud Lambiotte, "Encapsulation Structure and Dynamics in Hypergraphs", *Journal of Physics: Complexity* **4**, 045007 (2023).

:bdg-link-primary-line:`Paper <https://doi.org/10.1088/2632-072X/ad0b39>`
:bdg-link-primary-line:`Code <https://github.com/tlarock/encapsulation-dynamics>`
Expand Down
53 changes: 53 additions & 0 deletions docs/source/xgi-data.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
********
XGI-DATA
********

XGI-DATA is a repository of openly available hypergraph datasets in JSON format with corresponding documentation of network statistics, limitations of the data, and methods of collection. They are hosted in the `XGI Community <https://zenodo.org/communities/xgi>`_ on Zenodo. This is loosely inspired by `Datasheets for Datasets <https://arxiv.org/abs/1803.09010>`_ by Gebru et al.

Dataset format
--------------

The xgi-data format for higher-order datasets is a JSON data structure with the following structure:

* "hypergraph-data": This tag accesses the attributes of the entire hypergraph dataset such as the authors or dataset name.

* "node-data": This tag accesses the nodes of the hypergraph and their associated properties as a dictionary where the keys are node IDs and the corresponding values are dictionaries. If a node doesn't have any properties, the associated dictionary is empty.

* "name": This tag accesses the node's name if there is one that is different from the ID specified in the hyperedges.
* Other tags are user-specified based on the particular attributes provided by the dataset.

* "edge-data": This tag accesses the hyperedges of the hypergraph and their associated attributes.

* "name": This tag accesses the edge's name if one is provided.
* "timestamp": This is the tag specifying the time associated with the hyperedge if it is given. All times are stored in ISO8601 standard.
* Other tags are user-specified based on the particular attributes provided by the dataset.

* "edge-dict": This tag accesses the edge IDs and the corresponding nodes which participate in that hyperedge.

Loading datasets
----------------

Loading a dataset using XGI is as simple as the following two lines:

.. code-block:: python

import xgi
H = xgi.load_xgi_data("<dataset_name>")

XGI-DATA uses an HTTP request to load the hypergraph dataset.


Network Statistics
------------------

.. raw:: html

<style>

</style>

<script type="text/javascript">
display_table()
</script>

<p>More details on individual datasets are available at the <a href="https://github.com/xgi-org/xgi-data">XGI-DATA page</a>.</p>
Loading