Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
graphology-generators
Advanced tools
Various graph generators to be used with graphology
.
npm install graphology-generators
Creates a complete graph.
import Graph, {UndirectedGraph} from 'graphology';
import {complete} from 'graphology-generators/classic';
// Alternatively, if you only want to load relevant code
import complete from 'graphology-generators/classic/complete';
// Creating a complete graph
const graph = complete(Graph, 10);
// Using another constuctor to create, say, a complete undirected graph
const graph = complete(UndirectedGraph, 10);
Arguments
graphology
constructor.Creates an empty graph with the desired number of nodes and no edges.
import Graph, {UndirectedGraph} from 'graphology';
import {empty} from 'graphology-generators/classic';
// Alternatively, if you only want to load relevant code
import empty from 'graphology-generators/classic/empty';
// Creating an empty graph
const graph = empty(Graph, 10);
// Using another constuctor to create, say, an empty undirected graph
const graph = empty(UndirectedGraph, 10);
Arguments
graphology
constructor.Creates a ladder graph with the desired length. Note that the generated graph will logically have twice the number of nodes.
import Graph, {UndirectedGraph} from 'graphology';
import {ladder} from 'graphology-generators/classic';
// Alternatively, if you only want to load relevant code
import ladder from 'graphology-generators/classic/ladder';
// Creating a ladder graph
const graph = ladder(Graph, 10);
// Using another constuctor to create, say, a undirected ladder graph
const graph = ladder(UndirectedGraph, 10);
Arguments
graphology
constructor.Creates a path graph.
import Graph, {UndirectedGraph} from 'graphology';
import {path} from 'graphology-generators/classic';
// Alternatively, if you only want to load relevant code
import path from 'graphology-generators/classic/path';
// Creating a path graph
const graph = path(Graph, 10);
// Using another constuctor to create, say, a path undirected graph
const graph = path(UndirectedGraph, 10);
Arguments
graphology
constructor.Creates a Caveman graph containing l
components of k
nodes.
import Graph, {UndirectedGraph} from 'graphology';
import {caveman} from 'graphology-generators/community';
// Alternatively, if you only want to load relevant code
import caveman from 'graphology-generators/community/caveman';
// Creating a caveman graph
const graph = caveman(Graph, 6, 8);
Arguments
graphology
constructor.Creates a Connected Caveman graph containing l
components of k
nodes.
import Graph, {UndirectedGraph} from 'graphology';
import {connectedCaveman} from 'graphology-generators/community';
// Alternatively, if you only want to load relevant code
import connectedCaveman from 'graphology-generators/community/connected-caveman';
// Creating a connected caveman graph
const graph = connectedCaveman(Graph, 6, 8);
Arguments
graphology
constructor.Creates a graph with the desired number of nodes & edges and having a given number of clusters.
import Graph from 'graphology';
import {clusters} from 'graphology-generators/random';
// Alternatively, if you only want to load relevant code
import clusters from 'graphology-generators/random/clusters';
// Creating a random clustered graph
const graph = clusters(Graph, {
order: 100,
size: 1000,
clusters: 5
});
Arguments
graphology
constructor.0.5
]: Probability that an edge will link two nodes of the same cluster.Creates an Erdos-Renyi, or binomial graph.
import Graph from 'graphology';
import {erdosRenyi} from 'graphology-generators/random';
// Alternatively, if you only want to load relevant code
import erdosRenyi from 'graphology-generators/random/erdos-renyi';
// Creating a binomial graph
const graph = erdosRenyi(Graph, {order: 10, probability: 0.5});
// If your graph is sparse (low probability), you can use the `sparse` version
// which runs in O(m + n) rather than O(n^2)
const graph = erdosRenyi.sparse(Graph, {order: 1000, probability: 0.1});
Arguments
graphology
constructor.Creates a Girvan-Newman random graph as described in:
Community Structure in social and biological networks. Girvan Newman, 2002. PNAS June, vol 99 n 12
import Graph from 'graphology';
import {girvanNewman} from 'graphology-generators/random';
// Alternatively, if you only want to load relevant code
import girvanNewman from 'graphology-generators/random/girvan-newman';
// Creating a binomial graph
const graph = girvanNewman(Graph, {zOut: 4});
Arguments
graphology
constructor.Returns the Krackhardt kite graph.
import Graph from 'graphology';
import {krackhardtKite} from 'graphology-generators/small';
// Alternatively, if you only want to load relevant code
import krackhardtKite from 'graphology-generators/small/krackhardt-kite';
// Creating a random clustered graph
const graph = krackhardtKite(Graph);
Arguments
graphology
constructor.Returns the Florentine families' graph.
import Graph from 'graphology';
import {florentineFamilies} from 'graphology-generators/florentine-families';
// Alternatively, if you only want to load relevant code
import florentineFamilies from 'graphology-generators/social/florentine-families';
// Generating the graph
const graph = florentineFamilies(Graph);
Arguments
graphology
constructor.Returns Zachary's karate club graph.
import Graph from 'graphology';
import {karateClub} from 'graphology-generators/karate-club';
// Alternatively, if you only want to load relevant code
import karateClub from 'graphology-generators/social/karate-club';
// Generating the graph
const graph = karateClub(Graph);
Arguments
graphology
constructor.FAQs
Various graph generators for graphology.
The npm package graphology-generators receives a total of 5,677 weekly downloads. As such, graphology-generators popularity was classified as popular.
We found that graphology-generators demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.