SuiteSparseGraphBLAS.jl: Sparse, General Linear Algebra for Graphs!

SuiteSparseGraphBLAS.jl

A fast, general sparse linear algebra and graph computation package, based on SuiteSparse:GraphBLAS.

Installation

using Pkg
Pkg.add("SuiteSparseGraphBLAS")

Benchmarks

julia> using SuiteSparseGraphBLAS
# Standard arithmetic semiring (+, *) matrix multiplication
julia> s = sprand(Float64, 100000, 100000, 0.05);
julia> v = sprand(Float64, 100000, 1000, 0.1);
julia> @btime s * v
  157.211 s (8 allocations: 1.49 GiB)
julia> s = GBMatrix(s); v = GBMatrix(v);
# Single-threaded
julia> @btime s * v
  54.649 s (26 allocations: 1.49 GiB)
# 2 threads
julia> @btime s * v
  30.258 s (26 allocations: 1.50 GiB)
# 4 threads
julia> @btime s * v
  21.738 s (26 allocations: 1.54 GiB)

# Indexing
julia> s = sprand(Float64, 100000, 100000, 0.05);
julia> @btime s[1:10:end, end:-10:1]
  344.355 ms (11 allocations: 76.32 MiB)
julia> s = GBMatrix(s);
julia> @btime s[1:10:end, end:-10:1]
  81.750 ms (39 allocations: 152.49 MiB)

Citing SuiteSparse:GraphBLAS

If you use SuiteSparseGraphBLAS.jl in your research please cite the following three papers:

pdf:

    @article{10.1145/3322125,
    author = {Davis, Timothy A.},
    title = {Algorithm 1000: SuiteSparse:GraphBLAS: Graph Algorithms in the Language of Sparse Linear Algebra},
    year = {2019},
    issue_date = {December 2019},
    publisher = {Association for Computing Machinery},
    address = {New York, NY, USA},
    volume = {45},
    number = {4},
    issn = {0098-3500},
    url = {https://doi.org/10.1145/3322125},
    doi = {10.1145/3322125},
    journal = {ACM Trans. Math. Softw.},
    month = {dec},
    articleno = {44},
    numpages = {25},
    keywords = {GraphBLAS, Graph algorithms, sparse matrices}
    }

pdf:

    @article{GraphBLAS7,
  author = {Davis, Timothy A.},
  title = {Algorithm 10xx: SuiteSparse:GraphBLAS: Graph Algorithms in the Language of Sparse Linear Algebra},
  year = {2022},
  journal = {ACM Trans. Math. Softw.},
  month = {(under revision)},
  note={See GraphBLAS/Doc/toms_parallel_grb2.pdf},
  keywords = {GraphBLAS, Graph algorithms, sparse matrices}
}

pdf:

@INPROCEEDINGS{9622789,
author={Pelletier, Michel and Kimmerer, Will and Davis, Timothy A. and Mattson, Timothy G.},
booktitle={2021 IEEE High Performance Extreme Computing Conference (HPEC)},
title={The GraphBLAS in Julia and Python: the PageRank and Triangle Centralities},
year={2021},
pages={1-7},
doi={10.1109/HPEC49654.2021.9622789},
ISSN={2643-1971},
month={Sep.}
}

Acknowledgements

This work was funded as part of Google Summer of Code over 3 summers, 2 of which were for Abhinav Mehndiratta and the last of which was for William Kimmerer.

Original author: Abhinav Mehndiratta

SuiteSparse author: Tim Davis

Mentors: Viral B Shah, Miha Zgubic, Tim Davis

Current maintainer: William Kimmerer

Download Details:

Author: JuliaSparse
Source Code: https://github.com/JuliaSparse/SuiteSparseGraphBLAS.jl 
License: MIT license

#julia #graphs #analytics 

SuiteSparseGraphBLAS.jl: Sparse, General Linear Algebra for Graphs!

SimpleValueGraphs.jl: A LightGraphs.jl Compatible Graph Package

SimpleValueGraphs.jl

SimpleValueGraphs is a Graphs.jl compatible package for graphs with multiple, homogeneous vertex, edge and graph metadata. In particular it provides:

  • an abstract interface for graphs with metadata
  • concrete implementations of mutable graphs with metadata

Compared to SimpleWeightedGraphs.jl it has the following advantages:

  • vertex and graph metadata
  • multiple edge metadata
  • faster structural modifications of graphs

Compared to MetaGraphs.jl it has the following advantages:

  • faster access and modifications of metadata
  • better type stability when accessing metadata

Example

using SimpleValueGraphs

using Graphs: smallgraph
using Plots
using GraphRecipes: graphplot
using Colors: RGB, Color

# Load a Graphs.SimpleGraph
gs = smallgraph(:house)

# Convert to a ValGraph with vertex and edge values
gv = ValGraph(gs;
    # Two names vertex values:
    # - color: A random color
    # - label: The vertex identifier as a string
    vertexval_types=(color=Color, label=String),
    vertexval_init=v -> (rand(RGB), string(v)),
    # One unnamed edge value:
    # A string s -- d from source to destination of each edge
    edgeval_types=(String, ),
    edgeval_init=(s, d) -> ("$s -- $d",)
)

# Plot this graph using the vertex and edge values
graphplot(gv;
    nodecolor = [get_vertexval(gv, v, :color) for v in vertices(gv)],
    names = [get_vertexval(gv, v, :label) for v in vertices(gv)],
    edgelabel=weights(gv; zerovalue="")
)

example output

Benchmarks

This is a comparison of running Graphs.dijkstra_shortest_paths on the egonets-Facebook graph for multiple graph types.

graph typetime (ms)
Graphs.SimpleGraph + Matrix weights6.5
Graphs.SimpleGraph + SparseMatrixCSC weights11.4
SimpleWeightedGraphs.SimpleWeightedGraph11.7
MetaGraphs.MetaGraph141.9
SimpleValueGraphs.ValGraph12.4

Currently a lot of Graphs.jl algorithms do not optimally work with graphs that store edge metadata internally. The next benchmark is an optimized version of the same algorithm that can be found in SimpleValueGraphs.Experimental.dijkstra_shortests_pasts. Clearly, this is a huge improvement for ValGraph and SimpleWeightedGraph.

graph typetime (ms)
Graphs.SimpleGraph + Matrix weights6.8
Graphs.SimpleGraph + SparseMatrixCSC weights10.8
SimpleWeightedGraphs.SimpleWeightedGraph2.9
MetaGraphs.MetaGraph147.3
SimpleValueGraphs.ValGraph3.1

Download Details:

Author: Simonschoelly
Source Code: https://github.com/simonschoelly/SimpleValueGraphs.jl 
License: MIT license

#julia #graphs #algorithm 

SimpleValueGraphs.jl: A LightGraphs.jl Compatible Graph Package

SimpleGraphs.jl: Convenient Way to Handle Simple Graphs and Digraphs

SimpleGraphs

Release notes for version 0.8

We have made the following (breaking) changes:

  • SimpleGraph has been renamed UndirectedGraph.
  • SimpleDigraph has been renamed DirectedGraph.
  • SimpleHypergraph has been renamed HyperGraph (note the captial G).

These may be abbreviated as UG, DG, and HG, respectively

These changes were made to help this SimpleGraphs module be interoperable with Julia's Graphs module that defines the type SimpleGraph (formerly Graph in the LightGraphs module).

Conversion between these two types (UndirectedGraph in this module and SimpleGraph in the Graphs module) is supported; see the file graph_converter.jl in the extras directory.


Overview

This module defines three data types for working with graphs:

  • The UndirectedGraph type represents undirected graphs without loops or multiple edges.
  • The DirectedGraph type represents directed graphs in which there may be at most one directed edge (u,v) from a vertex u to a vertex v. There may also be a directed edge in the opposite direction, (v,u).
  • The HyperGraph type representing hypergraphs in which edges may be any subset of the vertex set.

Additional functionality can be found in these modules:

Not ready for prime time

In addition, we have:

User's Guide

Please see the Wiki for extensive information pertaining to the UndirectedGraph type.

The DirectedGraph type is not so well developed nor documented. See the source files in the src directory. Likewise, documentation and support for the HyperGraph type is limited.

A Few Extras

The extras directory contains some additional functionality that may be useful. See the README file therein.

Postcardware

This software is part of a larger suite of tools for graph theory. More information can be found right after my explanation that this code is postcardware.

Thanks

Thank you to JHU students Tara Abrishami and Laura Bao for contributions to this project.

Please Help

This is a work in process with a lot of more features that can/should be added. If you're interested in contributing, please contact me. I'm especially interested in JHU undergraduates getting involved.

Ed Scheinerman (ers@jhu.edu)

Download Details:

Author: Scheinerman
Source Code: https://github.com/scheinerman/SimpleGraphs.jl 
License: View license

#julia #graphs 

SimpleGraphs.jl: Convenient Way to Handle Simple Graphs and Digraphs

Multigraphs.jl: A Multigraph Extension Of Graphs.jl

Multigraphs

Multigraphs extension for Graphs.jl.

Installation

Multigraphs is a Julia Language   package. To install Multigraphs, please open Julia's interactive session (known as REPL) and press ] key in the REPL to use the package mode, then type the following command

pkg> add Multigraphs

Examples

using Graphs, Multigraphs

# create a undirected multigraph with 3 vertices and 0 multiple edges
# use DiMultigraph for directed multigraphs
julia> mg = Multigraph(3)
{3, 0} undirected Int64 multigraph with Int64 multiplicities

# add a multiple edge from 1 to 2 with multiplicity 2
julia> add_edge!(mg, 1, 2, 2)
true

# add a simple edge (multiple edge with multiplicity 1) from 2 to 3
julia> add_edge!(mg, 2, 3)
true

# this will increase multiplicity of the edge from 2 to 3 by 2
julia> add_edge!(mg, 2, 3, 2) 
true

# this will decrease multiplicity of the edge from 2 to 3 by 1
julia> rem_edge!(mg, 2, 3, 2) 

# here me is a MultipleEdge
julia> mes = [me for me in edges(mg)]
2-element Array{MultipleEdge{Int64,Int64},1}:
Multiple edge 1 => 2 with multiplicity 2
Multiple edge 2 => 3 with multiplicity 1

# here e is a Graphs.SimpleEdge
julia> for e in mes[1] 
           println(e)
       end
Edge 1 => 2
Edge 1 => 2

Download Details:

Author: QuantumBFS
Source Code: https://github.com/QuantumBFS/Multigraphs.jl 
License: MIT license

#julia #graphs 

Multigraphs.jl: A Multigraph Extension Of Graphs.jl

MatrixNetworks.jl: Graph and Network Algorithms in Julia

MatrixNetworks

This package consists of a collection of network algorithms. In short, the major difference between MatrixNetworks.jl and packages like LightGraphs.jl or Graphs.jl is the way graphs are treated.

In Graphs.jl, graphs are created through Graph() and DiGraph() which are based on the representation of $G$ as $G=(V,E)$. Our viewpoint is different.

MatrixNetworks is based on the philosophy that there should be no distinction between a matrix and a network - thus the name.

For example, d,dt,p = bfs(A,1) computes the bfs distance from the node represented by row 1 to all other nodes of the graph with adjacency matrix A. (A can be of type SparseMatrixCSC or MatrixNetwork). This representation can be easier to work with and handle.

The package provides documentation with sample runs for all functions - viewable through Julia’s REPL. These sample runs come with sample data, which makes it easier for users to get started on MatrixNetworks.

Package Installation:

To install package

using Pkg
Pkg.add("MatrixNetworks")
using MatrixNetworks

Example

?bfs
?bipartite_matching

To run test cases:

Pkg.test("MatrixNetworks")

Data available:

For a full list of all datasets:

matrix_network_datasets()

Loading data example:

load_matrix_network("clique-10")

Some examples:

largest_component: Return the largest connected component of a graph

  • Acc is a sparse matrix containing the largest connected piece of a directed graph A
  • p is a logical vector indicating which vertices in A were chosen
A = load_matrix_network("dfs_example")
Acc,p = largest_component(A)

clustercoeffs: Compute undirected clustering coefficients for a graph

  • cc is the clustering coefficients
A = load_matrix_network("clique-10")
cc = clustercoeffs(MatrixNetwork(A))

bfs: Compute breadth first search distances starting from a node in a graph

  • d is a vector containing the distances of all nodes from node u (1 in the example below)
  • dt is a vector containing the discover times of all the nodes
  • pred is a vector containing the predecessors of each of the nodes
A = load_matrix_network("bfs_example")
d,dt,pred = bfs(A,1)

scomponents: Compute the strongly connected components of a graph

A = load_matrix_network("cores_example")
sc = scomponents(A)
sc.number #number of connected componenets
sc.sizes #sizes of components
sc.map #the mapping of the graph nodes to their respective connected component
strong_components_map(A) # if you just want the map
sc_enrich = enrich(sc) # produce additional enriched output includes:
sc_enrich.reduction_matrix
sc_enrich.transitive_map
sc_enrich.transitive_order

Can work on ei,ej:

ei = [1;2;3]
ej = [2;4;1]
scomponents(ei,ej)

bipartite_matching: Return a maximum weight bipartite matching of a graph

ei = [1;2;3]
ej = [3;2;4]
BM = bipartite_matching([10;12;13],ei,ej)
BM.weight
BM.cardinality
BM.match
create_sparse(BM) # get the sparse matrix
edge_list(BM) # get the edgelist
edge_indicator(BM,ei,ej) # get edge indicators

Download Details:

Author: JuliaGraphs
Source Code: https://github.com/JuliaGraphs/MatrixNetworks.jl 
License: View license

#julia #graphs #network 

MatrixNetworks.jl: Graph and Network Algorithms in Julia

GraphViz.jl: Julia Binding to The GraphViz Library

GraphViz.jl

This package provides an interface to the the GraphViz package for graph visualization. There are two primary entry points:

  • The GraphViz.load function (not exported) to load graphs from a file
  • The dot""" string macro for literal inline specifications of graphs

Both of these accept Graph type accepts graph in DOT format. To load a graph from a non-constant string, use GraphViz.load with an IOBuffer.

Getting started

If you already have a graph you would like to work with, the following code snippets may be helpful. If not, have a look at the "Simple Examples" section below

using GraphViz
GraphViz.load("mygraph.dot")
dot"""
 digraph graphname {
     a -> b -> c;
     b -> d;
 }
""")

Usage

After obtaining the package through the package manager, the following suffices to load the package:

using GraphViz

Note that graphviz has many configuration options. In particular, both the Cairo and the GTK backends may be disabled by default.

Simple Examples

Try the following in an IJulia Notebook (this example is taken from here):

dot"""
graph graphname {
     // The label attribute can be used to change the label of a node
     a [label="Foo"];
     // Here, the node shape is changed.
     b [shape=box];
     // These edges both have different line properties
     a -- b -- c [color=blue];
     b -- d [style=dotted];
 }
"""

Download Details:

Author: JuliaGraphs
Source Code: https://github.com/JuliaGraphs/GraphViz.jl 
License: View license

#julia #graphs #binding 

GraphViz.jl: Julia Binding to The GraphViz Library

NetworkViz.jl: Julia Interface to visualize Graphs

NetworkViz

A Julia module to render graphs in 3D using ThreeJS tightly coupled with LightGraphs.

Install

In a Julia REPL, run:

Pkg.add("NetworkViz")

Graph Algorithms Used

Graph Primitives

NodeProperty

The NodeProperty type stores the properties of each node in the graph. It stores the following properties :

  • color : It is a Colors array that stores the colors of all the nodes in the graph.
  • size : Size of the node. eg : 0.2.
  • shape : Shape of the node. Can be 0 or 1. 0 - Square, 1 - Circle.

EdgeProperty

The EdgeProperty type stores the properties of each edge in the graph. It stores the following properties :

  • color : It is a hex string that stores the color of the edges.
  • width : Thickness of the edges. eg : 1.5.

Visualizing Graphs

The drawGraph function can be used to draw the graphs in 2D or 3D with nodes having different colors. It can accept LightGraphs.Graph and LightGraphs.Digraph types. drawGraph can be used to draw graphs from adjacency matrices also. The function accepts an additional kwargs node::NodeProperty, edge::EdgeProperty, and z. If z=1, it draws a 3D graph. If z=0, a 2D visualization of the graph is drawn. node and edge determines the properties of nodes and edges respectively.

Usage :

g = CompleteGraph(10)
c = Color[parse(Colorant,"#00004d") for i in 1:nv(g)]
n = NodeProperty(c,0.2,0)
e = EdgeProperty("#ff3333",1)
drawGraph(g,node=n,edge=e,z=1) #Draw using a Graph object (3D).

am = full(adjacency_matrix(g))
drawGraph(am,node=n,edge=e,z=0) #Draw using an adjacency matrix (2D).

dgraph = bfs_tree(g,1)
drawGraph(dgraph,z=1) #Draw a Digraph.

Utility Functions

  • addEdge(g::Graph,node1::Int,node2::Int,z=1) - Add a new edge node1-node2 and redraws the graph. z toggles 2D-3D conversion. Fails silently if an already existing node is added again.
  • removeEdge(g::Graph,node1::Int,node2::Int,z=1) - Removes the edge node1-node2 if it exists and redraws the graph. z toggles 2D-3D conversion.
  • addNode(g::Graph,z=1) - Adds a new node to the graph. z toggles 2D-3D conversion.
  • removeNode(g::Graph,node::Int,z=1) - Removes node if it exists and redraws the graph. z toggles 2D-3D conversion.

Examples

#Run this code in Escher
using NetworkViz
using LightGraphs
main(window) = begin
  push!(window.assets, "widgets")
  push!(window.assets,("ThreeJS","threejs"))
  g = CompleteGraph(10)
  drawGraph(g)
end

The above code produces the following output :

alt tag

Here is another example with a code-mirror where functions can be typed in. Depending on the LightGraphs function used, 2D as well as 3D graphs are drawn. You can see the working demo here.

You can find many other examples in the examples/ folder.

Acknowledgement

IainNZ for the original Spring-Embedder code. (Taken from GraphLayout.jl).

Download Details:

Author: Abhijithanilkumar
Source Code: https://github.com/abhijithanilkumar/NetworkViz.jl 
License: View license

#julia #graphs #interface 

NetworkViz.jl: Julia Interface to visualize Graphs
Lawrence  Lesch

Lawrence Lesch

1662360604

Palette.js: Script for Generating Colour Palettes For Use with Graphs

Colour Palette Generator

The palette.js script allows to generate palette colours and was intended for use with graphs, charts and cartography. In default setup, it contains Paul Tol's and ColorBrewer palettes specifically designed for that purpose. The library includes several qualitative, sequential and diverging colour schemes

Some of the included palettes have a limited number of colours, but others use a colour generation functions and can potentially create a whole spectrum of colours.

There is an interactive demo of the library if you wish to see what it can do.

Naming

The basic two concepts in palette.js library are schemes and palettes. It is important to understand what they are so as to understand the API of the library.

A palette is a sequence of colours and it is represented by an array of colours encoded as “RRGGBB” strings. Palette has a fixed size or number of colours in it. For example, the following code defines a 8-colour palette which is a sequence of base colours of the Solarized palette:

var sol_base = ['002b36', '073642', '586e75', '657b83',
                '839496', '93a1a1', 'eee8d5', 'fdf6e3'];

A scheme is a set of colour palettes and it is represented by a function with some additional properties and methods (i.e. it can be used as an object). In simplest cases, scheme will be used to generate a palette of desired size. For example, if hsv_rainbow is an HSV rainbow scheme, the following code generates a 6-colour palette based on the scheme:

var hsv6 = hsv_rainbow(6);

Library quick start

The simplest way to access the library is by calling palette function. It takes two required arguments: A name of a colour scheme and size of the palette. For example to generate a 10-colour palette one would invoke:

var seq = palette('tol-sq', 10);

tol-sq is a name for Paul Tol's sequential scheme. In addition to names of schemes the function can also take group names or a list of palette names. For example:

var seq = palette('sequential', 10);
var cbf = palette('sequential-cbf', 10);

will take the first available sequential colour scheme and generate 10-colour palette storing it in seq. The second line does the same except it limits the palettes to only those that are colour blind friendly.

The argument can also be a list of colour schemes as in:

var div = palette(['tol', 'qualitative'], 10);

Here, div will be assigned an array of colours from Paul Tol's qualitative scheme unless it is not available in which case the first available qualitative colour scheme will be used.

Another use of a list of schemes or group names is a third optional argument to the palette function -- the index for the scheme to use. When specified, not the first one, but the given scheme will be used (indexed from zero). This can be used to generate distinct colour palettes for various types of data.

var pal_for_queries = palette(['sequential'], 10, 0);
var pal_for_errors = palette(['sequential'], 10, 1);
var pal_for_latency = palette(['sequential'], 10, 2);

With the above code, three separate 10-colour palettes will be generated each for different kind of data.

If no schemes matched specified name(s), palette function will return null.

For a full reference please see the source code.

Note on colour blindness

A palette can be colour blind friendly, or CBF, meaning that colours in it are distinguishable by a colour blind person. Scheme can also be colour blind friendly (for example all Paul Tol's schemes are), but more often only some of the palettes in given scheme are (for example a 4-colour palette based on ColorBrewer Paired scheme is CBF, but bigger palettes aren't).

The demo page contains code for colour blindness simulation mode.

Download Details:

Author: Google
Source Code: https://github.com/google/palette.js 
License: Unknown and 3 other licenses found

#javascript #script #graphs #charts 

Palette.js: Script for Generating Colour Palettes For Use with Graphs

OldGraphs.jl: Working with Graphs in Julia

Graphs.jl  

This is an archived copy of the old Graphs.jl package, which is retained solely for the issues and pull-requests. The new repository for Graphs.jl is https://github.com/JuliaGraphs/Graphs.jl, which includes all the code from this repo along with the development history of LightGraphs, which was later renamed to Graphs and merged into that combined repository. As the name "Graphs" suggests, this was the original graph package in Julia. By 2016, however, it had become largely unmaintained. Another graphs package named LightGraphs, focused on a slightly different set of use cases, eventually became the de facto standard graphs package in the Julia ecosystem. In 2021, the primary author of LightGraphs departed and the name was retired at their request. At that point, the code base of LightGraphs was grafted back into a forked copy of the Graphs repository, which now lives in the JuliaGraphs organization, wholesale replacing the content of this archived repository. So Graphs was the original graph library; then LightGraphs became the standard; then LightGraphs was renamed to Graphs and replaced the code of the old Graphs, which is what you're looking at here. Yes, it's all a bit confusing—sorry about that. What follows is the README of the original Graphs package.


Graphs.jl is a Julia package that provides graph types and algorithms. The design of this package is inspired by the Boost Graph Library (e.g. using standardized generic interfaces), while taking advantage of Julia's language features (e.g. multiple dispatch). This library allows storing of own information in the graph structure -- useful in many cases.

Main Features

An important aspect of Graphs.jl is the generic abstraction of graph concepts expressed via standardized interfaces, which allows access to a graph's structure while hiding the implementation details. This encourages reuse of data structures and algorithms. In particular, one can write generic graph algorithms that can be applied to different graph types as long as they implement the required interface.

In addition to the generic abstraction, there are other important features:

A variety of graph types tailored to different purposes

  • generic adjacency list
  • generic incidence list
  • a simple graph type with compact and efficient representation
  • an extended graph type that supports labels and attributes

A collection of graph algorithms:

  • graph traversal with visitor support: BFS, DFS
  • cycle detection
  • connected components
  • topological sorting
  • shortest paths: Dijkstra, Floyd-Warshall, A*
  • minimum spanning trees: Prim, Kruskal
  • maximal cliques
  • random graph generation: Erdős–Rényi, Watts-Strogatz (see the RandomGraphs.jl package for more random graph models)
  • more algorithms are being implemented

Matrix-based characterization: adjacency matrix, weight matrix, Laplacian matrix

All data structures and algorithms are implemented in pure Julia, and thus they are portable.

We paid special attention to the runtime performance. Many of the algorithms are very efficient. For example, a benchmark shows that it takes about 15 milliseconds to run the Dijkstra's algorithm over a graph with 10 thousand vertices and 1 million edges on a macbook pro.

Documentation

Please refer to Graphs.jl Documentation for latest documentation.

Download Details:

Author: JuliaAttic
Source Code: https://github.com/JuliaAttic/OldGraphs.jl 
License: View license

#julia #graphs 

OldGraphs.jl: Working with Graphs in Julia

GraphCentrality.jl: Centrality Measures for Graphs.jl

GraphCentrality.jl

Optimized, performance-driven centrality measures on Graphs.jl graphs.

Please note that this package is not actively maintained. Active development of centrality measures has been moved to the LightGraphs.jl project.

Centrality Test(order, size)GraphCentrality.jlNetworkXImprovement
degree(1e6, 1e7)0.30s30.7s99%
betweenness(500, 50000)4.25s9.13s53%
closeness(1000, 80000)2.18s12.1s77%

TODO

  • Finish betweenness_centrality with dijkstra
  • Optimize code
  • TESTS!
  • New centrality measures:
  • Closeness
  • Load
  • Eigenvector
  • Current flow betweenness?
  • Current flow closeness?

Download Details:

Author: JuliaGraphs
Source Code: https://github.com/JuliaGraphs/GraphCentrality.jl 
License: View license

#julia #graphs 

GraphCentrality.jl: Centrality Measures for Graphs.jl
Reid  Rohan

Reid Rohan

1658297160

Sigma.js: JavaScript Library Aimed At Visualizing Graphs Of Thousands

sigma.js - v1.2.1

Sigma is a JavaScript library dedicated to graph drawing, mainly developed by @jacomyal and @Yomguithereal.

Resources

The website provides a global overview of the project, and the documentation is available in the GitHub Wiki.

Also, the plugins and examples directories contain various use-cases that might help you understand how to use sigma.

How to use it

To use it, clone the repository:

git clone git@github.com:jacomyal/sigma.js.git

To build the code:

  • Install Node.js.
  • Install gjslint.
  • Use npm install to install sigma development dependencies.
  • Use npm run build to minify the code with Uglify. The minified file sigma.min.js will then be accessible in the build/ folder.

Also, you can customize the build by adding or removing files from the coreJsFiles array in Gruntfile.js before applying the grunt task.

Contributing

You can contribute by submitting issues tickets and proposing pull requests. Make sure that tests and linting pass before submitting any pull request by running the command grunt.

The whole source code is validated by the Google Closure Linter and JSHint, and the comments are written in JSDoc (tags description is available here).

Author: jacomyal
Source Code: https://github.com/jacomyal/sigma.js 
License: MIT license

#javascript #graphs #nodes 

Sigma.js: JavaScript Library Aimed At Visualizing Graphs Of Thousands
Reid  Rohan

Reid Rohan

1658284320

Dygraphs: Interactive Visualizations Of Time Series using JavaScript

dygraphs JavaScript charting library

The dygraphs JavaScript library produces interactive, zoomable charts of time series:

Learn more about it at dygraphs.com.

Get help with dygraphs by browsing the on Stack Overflow (preferred) and Google Groups.

Features

Minimal Example

<html>
<head>
<script type="text/javascript" src="dygraph.js"></script>
<link rel="stylesheet" href="dygraph.css" />
</head>
<body>
<div id="graphdiv"></div>
<script type="text/javascript">
  g = new Dygraph(
        document.getElementById("graphdiv"),  // containing div
        "Date,Temperature\n" +                // the data series
        "2008-05-07,75\n" +
        "2008-05-08,70\n" +
        "2008-05-09,80\n",
        { }                                   // the options
      );
</script>
</body>
</html>

Learn more by reading the tutorial and seeing demonstrations of what dygraphs can do in the gallery. You can get dygraph.js and dygraph.css from cdnjs or from NPM (see below).

Usage with a module loader

Get dygraphs from NPM:

npm install dygraphs

You'll find pre-built JS & CSS files in node_modules/dygraphs/dist. If you're using a module bundler like browserify or webpack, you can import dygraphs:

import Dygraph from 'dygraphs';
// or: const Dygraph = require('dygraphs');

const g = new Dygraph('graphdiv', data, { /* options */ });

Check out the dygraphs-es6 repo for a fully-worked example.

Development

To get going, clone the repo and run:

npm install
npm run build

Then open tests/demo.html in your browser.

Read more about the dygraphs development process in the developer guide.

Author: Danvk
Source Code: https://github.com/danvk/dygraphs 
License: MIT license

#javascript #graphs #visualization #canvas 

Dygraphs: Interactive Visualizations Of Time Series using JavaScript
Lawrence  Lesch

Lawrence Lesch

1656352680

Instant XKCD-style Graphs Created In Javascript D3 for Your Enjoyment

Create your own XKCD-style Graphs

Original xkcd.js script created by Dan Foreman-Mackey. Simple graph creation UI by Kevin Xu and Charlie Guo.

See Example Graphs

  • sin(x) and cos(x)
  • x^2, -x^2, 2x, and 80
  • x * cos(x)

Example Graphs

Author: imkevinxu
Source Code: https://github.com/imkevinxu/xkcdgraphs 
License: 

#javascript #3d #graphs 

Instant XKCD-style Graphs Created In Javascript D3 for Your Enjoyment
Gordon  Taylor

Gordon Taylor

1656220620

insights: A JavaScript Library to Visualize and Navigate Graphs

Insights.js

A JavaScript library to visualize and navigate graphs.

Installation

With component.js

Insights can be installed with component.js.

$ component install ignacioola/insights

Without component.js

Add the insights.standalone.js and insights.standalone.css files located under build/ to your webpage.

Usage

var Insights = require("insights");

Example Data

var nodes = [
    {
        id: 1,
        text: "apple",
        size: 9,
        cluster: 5
    },
    {
        id: 2,
        text: "google",
        size: 7,
        cluster: 2
    },
    {
        id: 3,
        text: "microsoft",
        size: 5,
        cluster: 1
    }
];

var links = [
    [ 1, 2 ], // [ source.id, target.id ]
    [ 2, 3 ],
    [ 1, 3 ]
];

How to use it ?

var el = document.getElementById("container");
var graph = new Insights(el, nodes, links).render();

Adding a an event handler

graph.on("rendered", function() {
    // hide loader, ...
});

Events

  • rendered: when the graph has finished rendering.
  • no match: when a filter is applied and no matching nodes where found.
  • node:click: when a node is clicked.
  • node:mouseover: when the mouse is over a node.
  • node:mouseout: when the mouse goes out from a node.

Filtering

The filter function decides which nodes are visible and which are not. Always after applying filters the graph must be updated by calling update().

graph.filters({...}).update();

To return to the graph initial state, you can call reset().

graph.reset();

Filter by id

graph.filter({ id: 1 });

Filter by partial text match

graph.filter({ text: "micro" });

Filter by size


// filter by a range of values

graph.filter({ size: [1, 15] });

// filter greater than.. 

graph.filter({ size: [1, null] });

// filter lower than..

graph.filter({ size: [null, 15] });

Filter by clusters

graph.filter({ cluster: 1 })

//  or multi-cluster filter...

graph.filter({ cluster: [1, 2, 3] })

Filtering by more than one value

graph.filter({ text: "app", size: [1, 15], cluster: 0 })

Custom filters

graph.filter(function(node) {
  if (node.text == "something") {
    return true;
  } else {
    return false;
  }
})

Focusing

With .focus() you can decide which node and it's relations get highlighted.

Focusing by id

graph.focus(1);

//  or

graph.focus({ id: 1 });

Focus a node and it's incoming relations

graph.focus(1, { in: true })

Focus a node and it's outgoing relations

graph.focus(1, { out: true })

Focusing by exact text match

graph.focus({ text: "Apple" })

This will focus the graph on the first node that matches exactly the given text.

Method chaining

You can apply filters even in the focused state.

graph.focus({ id: 1 })
     .filter({ size: [50, 100] })
     .zoom(.2)
     .update()

Adding a tooltip

Using mustache synthax:

graph.tooltip("<div>name: {{text}}</div><div>count: {{size}}</div>")

API

Insights(el, nodes:array, links:array, options:obj)

Creates a new graph on the el element with the given nodes and links.

Available options include:

  • width: the graph width.
  • height: the graph height.
  • collisionAlpha: used when trying to solve collisions to determine how far from each other to position nodes. Defaults to 0.5.
  • initialScale: the chart's initial scale.
  • tooltip: adds a tooltip with the passed template if a string if passed. If you pass a truthy value, that's not a string it uses the default template.
  • colors: an object containing the colors for each cluster. For example: { "0": "blue", "1": "#FF0000" } .

.filter(fn|obj)

Selects all the nodes that for which fn result evaluates to true or if an object passed by all of it's values.

.focus(fn|obj|id, options:obj)

Focuses the graph on the first node that matches the passed parameters.

Available options include:

  • in: highlight incoming relations.
  • out: highlight outgoing relations.

.reset()

It returns the graph to it's original state.

.center(id)

Centers the graph. If there's a focused node it will be centered around it, if not it will center the graph on the mass center. If a node id is passed, it centers the graph around it.

.zoom(scale)

Zooms the graph to the given scale.

.zoomIn()

Zooms in the graph.

.zoomOut()

Zooms out the graph.

.getClusters()

Returns an object with the available clusters.

.tooltip(template:str)

Adds a tooltip with the given template to the node:mouseover event.

Used in

IMPORTANT: THIS PROJECT IS NO LONGER MAINTAINED

Author: ignacioola
Source Code: https://github.com/ignacioola/insights 
License: MIT

#javascript #d3 #graphs 

insights: A JavaScript Library to Visualize and Navigate Graphs
Reid  Rohan

Reid Rohan

1656177960

A D3.js Plugin That Produces Flame Graphs From Hierarchical Data

d3-flame-graph

A D3.js plugin that produces flame graphs from hierarchical data.

Flame Graph Example

If you don't know what flame graphs are, check Brendan Gregg's post.

Flame graphs are a visualization of profiled software, allowing the most frequent code-paths to be identified quickly and accurately. They can be generated using my open source programs on github.com/brendangregg/FlameGraph, which create interactive SVGs.

Brendan Gregg

Getting Started

jsdelivr CDN

Just reference the CDN hosted CSS and JS files!

<head>
  <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/d3-flame-graph@4.1.3/dist/d3-flamegraph.css">
</head>
<body>
  <div id="chart"></div>
  <script type="text/javascript" src="https://d3js.org/d3.v7.js"></script>
  <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/d3-flame-graph@4.1.3/dist/d3-flamegraph.min.js"></script>
  <script type="text/javascript">
  var chart = flamegraph()
    .width(960);

  d3.json("data.json")
    .then(data => {
      d3.select("#chart")
        .datum(data)
        .call(chart);
    }).catch(error => {
      return console.warn(error);
    });
  </script>
</body>

NPM

Make sure Node and npm installed on your system.

Install the d3-flame-graph plugin.

$ npm install d3-flame-graph --save

And use it!

<head>
  <link rel="stylesheet" type="text/css" href="node_modules/d3-flame-graph/dist/d3-flamegraph.css">
</head>
<body>
  <div id="chart"></div>
  <script type="text/javascript" src="node_modules/d3/d3.js"></script>
  <script type="text/javascript" src="node_modules/d3-flame-graph/dist/d3-flamegraph.js"></script>
  <script type="text/javascript">
  var chart = flamegraph()
    .width(960);
  
  d3.json("data.json")
    .then((data) => {
      d3.select("#chart")
        .datum(data)
        .call(chart);
    })
    .catch(error => {
      return console.warn(error);
    });
  </script>
</body>

More detailed examples in the /examples directory.

Input Format

Input stack is a simple hierarchical data structure in JSON format.

{
  "name": "<name>",
  "value": <value>,
  "children": [
    <Object>
  ]
}

The burn CLI tool can convert multiple file formats to this hierarchical data structure.

Interacting with entries

Internally, the data is transformed into a d3 hierarchy. Functions like onClick, label and zoom expose individual entries as hierarchy Nodes, which wrap the provided data and add more properties:

{
  "data": <original user-provided object>,
  "parent": <another hierarchy node>,
  "children": [
    <hierarchy node>
  ],
  "x1": <double>,  // x2 - x1 is the size of this node, as a fraction of the root.
  "x2": <double>
}

This is a breaking change from previous versions of d3-flame-graph, which were based on version 3 of the d3 library. See d3-hierarchy.

API Reference

# flamegraph()

Create a new Flame Graph.

# flamegraph.selfValue([enabled])

Defines if the plugin should use the self value logic to calculate the node value for the Flame Graph frame size. If set to true, it will assume the node value from the input callgraph represents only the internal node value, or self value, not the sum of all children. If set to false it will assume the value includes the chidren values too. Defaults to false if not explicitely set, which if the same behavior 1.x had.

# flamegraph.width([size])

Graph width in px. Defaults to 960px if not set. If size is specified, it will set the graph width, otherwise it will return the current graph width.

# flamegraph.height([size])

Graph height in px. Defaults to the number of cell rows times cellHeight if not set. If size is specified, it will set the cell height, otherwise it will return the current graph height. If minHeight is specified, and higher than the provided or calculated values, it will override height.

# flamegraph.minHeight([size])

Minumum graph height in px. If size is specified, and higher than the provided or calculated height, it will override it.

# flamegraph.cellHeight([size])

Cell height in px. Defaults to 18px if not set. If size is specified, it will set the cell height, otherwise it will return the current cell height.

# flamegraph.minFrameSize([size])

Minimum size of a frame, in px, to be displayed in the flame graph. Defaults to 0px if not set. If size is specified, it will set the minimum frame size, otherwise it will return the current minimum frame size.

# flamegraph.title([title])

Title displayed on top of graph. Defaults to empty if not set. If title is specified, it will set the title displayed on the graph, otherwise it will return the current title.

# flamegraph.tooltip([function])

Sets a tooltip for the flamegraph frames. The tooltip function should implement two methods, .show(d) and .hide(), that will be called when the tooltip should be made visible or hidden respectively. The .show method takes a single argument, which is the flamegraph frame. The d3-flame-graph package includes a simple tooltip function, flamegraph.tooltip.defaultFlamegraphTooltip().

<script type="text/javascript" src="d3-flamegraph-tooltip.js"></script>
var tip = flamegraph.tooltip.defaultFlamegraphTooltip()
    .text(d => "name: " + d.data.name + ", value: " + d.data.value);
flamegraph.tooltip(tip)

# flamegraph.transitionDuration([duration])

Specifies transition duration in milliseconds. The default duration is 750ms. If duration is not specified, returns the current transition duration.

See d3.duration.

# flamegraph.transitionEase([ease])

Specifies the transition easing function. The default easing function is d3.easeCubic.

See d3-ease.

# flamegraph.label([function])

Adds a function that returns a formatted label. Example:

flamegraph.label(function(d) {
    return "name: " + d.name + ", value: " + d.value;
});

# flamegraph.sort([enabled])

Enables/disables sorting of children frames. Defaults to true if not set to sort in ascending order by frame's name. If set to a function, the function takes two frames (a,b) and returns -1 if frame a is less than b, 1 if greater, or 0 if equal. If a value is specified, it will enable/disable sorting, otherwise it will return the current sort configuration.

# flamegraph.inverted([bool])

Invert the flame graph direction. A top-down visualization of the flame graph, also known as icicle plot. Defaults to false if not set. If a value is specified, it will enable/disable the inverted flame graphs direction, otherwise it will return the current inverted configuration.

# flamegraph.computeDelta([bool])

If enabled, computes delta for all nodes. Delta value of each node is a sum of its own value from the getDelta(node) function, plus its children. Defaults to false if not set. If a value is specified, it will enable/disable the delta computation, otherwise it will return the current computeDelta configuration.

# flamegraph.resetZoom()

Resets the zoom so that everything is visible.

# flamegraph.onClick([function])

Adds a function that will be called when the user clicks on a frame. Example:

flamegraph.onClick(function (d) {
    console.info("You clicked on frame "+ d.data.name);
});

If called with no arguments, onClick will return the click handler.

# flamegraph.onHover([function])

Adds a function that will be called when the user hovers on a frame. Example:

flamegraph.onHover(function (d) {
    console.info("You hovered over frame "+ d.data.name);
});

If called with no arguments, onHover will return the hover handler.

# flamegraph.setDetailsElement([element])

Sets the element that should be updated with the focused sample details text. Example:

<div id="details">
</div>
flamegraph.setDetailsElement(document.getElementById("details"));

If called with no arguments, setDetailsElement will return the current details element.

# flamegraph.setDetailsHandler([function])

Sets the handler function that is called when the details element needs to be updated. The function receives a single paramenter, the details text to be set. Example:

let detailsHandler = function (d) {
    if (detailsElement) {
        if (d) {
            detailsElement.textContent = d
        } else {
            if (typeof searchDetails === 'function') {
                searchDetails()
            } else {
                detailsElement.textContent = ''
            }
        }
    }
}
flamegraph.setDetailsHandler(
  function (d) {
    if (detailsElement) {
        if (d) {
            detailsElement.textContent = d
        } else {
            detailsElement.textContent = ''
        }
    }
  }
);

If not set, setDetailsHandler will default to the above function.

If called with no arguments, setDetailsHandler will reset the details handler function.

# flamegraph.setSearchHandler([function])

Sets the handler function that is called when search results are returned. The function receives a three paramenters, the search results array, the search sample sum, and root value, Example:

let searchHandler = function (searchResults, searchSum, totalValue) {
    searchDetails = () => {
        if (detailsElement) {
            detailsElement.textContent = 'search: ' + searchSum + ' of ' + totalValue + ' total samples ( ' + format('.3f')(100 * (searchSum / totalValue), 3) + '%)'
        }
    }
    searchDetails()
}
flamegraph.setSearchHandler(
  (searchResults, searchSum, totalValue) => {
    searchDetails = () => { // searchDetails is a global variable
        if (detailsElement) {
            detailsElement.textContent = 'search: ' + searchSum + ' of ' + totalValue + ' total samples ( ' + format('.3f')(100 * (searchSum / totalValue), 3) + '%)'
        }
    }
    searchDetails()
  }
);

If not set, setSearchHandler will default to the above function.

If called with no arguments, setSearchHandler will reset the search handler function.

# flamegraph.setColorMapper([function])

Replaces the built-in node color hash function. Function takes two arguments, the node data structure and the original color string for that node. It must return a color string. Example:

// Purple if highlighted, otherwise the original color
flamegraph.setColorMapper(function(d, originalColor) {
    return d.highlight ? "#E600E6" : originalColor;
});

If called with no arguments, setColorMapper will reset the color hash function.

# flamegraph.setColorHue([string])

Sets the flame graph color hue. Options are warm, cold, blue, red, orange, yellow, green, pastelgreen and aqua.

If called with no arguments, setColorHue will reset the color hash function.

# flamegraph.setSearchMatch([function])

Replaces the built-in node search match function. Function takes three arguments, the node data structure, the search term and an optional boolean argument to ignore case during search. If the third argument is not provided, the search will be case-sensitive by default. The function must return a boolean. Example:

flamegraph.setSearchMatch(function(d, term, true) {
  // Non-regex implementation of the search function
  return d.data.name.indexOf(term) != 0;
})

If called with no arguments, setSearchMatch will return reset the search match function.

# flamegraph.merge(date)

Merges the current data with the given data.

# flamegraph.update([data])

Updates the current chart. If the data parameters is passed, replaces the current data.

# flamegraph.destroy()

Removes the flamegraph.

All API functions will return the flame graph object if no other behavior is specified in the function details.

Issues

For bugs, questions and discussions please use the GitHub Issues.

Contributing

We love contributions! But in order to avoid total chaos, we have a few guidelines.

If you found a bug, have questions or feature requests, don't hesitate to open an issue.

If you're working on an issue, please comment on it so we can assign you to it.

If you have code to submit, follow the general pull request format. Fork the repo, make your changes, and submit a pull request.

Build

This plugin uses Webpack as build system. It includes a development server with live refresh on any changes. To start it, just execute the serve npm script.

$ git clone https://github.com/spiermar/d3-flame-graph.git
$ cd d3-flame-graph
$ npm install
$ npm run serve

Template

A standalone template with all JavaScript and CSS inlined gets built at dist/templates/d3-flamegraph-base.html. It contains a placeholder /** @flamegraph_params **/ which needs to be replaced with the stacks in the format described in Input Format.

Examples

Click here to check the demo, and source.

Click here to check the animated assembly demo, and source

Click here to check the simplified demo on bl.ocks.org.

Author: Spiermar
Source Code: https://github.com/spiermar/d3-flame-graph 
License: Apache-2.0 license

#javascript #d3 #graphs 

A D3.js Plugin That Produces Flame Graphs From Hierarchical Data