Cyjs.NET is an interface for Cytoscape.js written in F# to visualiz complex networks and integrate these with any type of attribute data.
The following examples show how easy it is to start working with Cyjs.NET.
You can get all Cyjs.NET packages from nuget at nuget page.
Or add the package reference directly to your
<PackageReference Include="Cyjs.NET" Version="<desired-version-here>" />
You can include the package via an inline package reference:
#r "nuget: Cyjs.NET, <desired-version-here>"
The general design philosophy of Cyjs.NET implements the following visualization flow:
Cytoscapeobject by using the
CyGraph module contains the
CyGraph.initEmpty function to create an empty graph.
You can therefore initialize a cytoscape graph like this:
open Cyjs.NET let myFirstGraph = CyGraph.initEmpty ()
Elements module contains the
edge functions to create the respective element.
Node and edges can be decorated with data as
You can therefore create a cytoscape graph with two nodes and an edge like this:
open Elements let myGraph = CyGraph.initEmpty () |> CyGraph.withElements [ node "n1" [ CyParam.label "FsLab" ] node "n2" [ CyParam.label "ML" ] edge "e1" "n1" "n2"  ]
Styling functions are generally the
CyGraph.with* naming convention. The following styling example does:
let myFirstStyledGraph = CyGraph.initEmpty () |> CyGraph.withElements [ node "n1" [ CyParam.label "FsLab" ] node "n2" [ CyParam.label "ML" ] edge "e1" "n1" "n2"  ] |> CyGraph.withStyle "node" [ CyParam.content =. CyParam.label CyParam.color "#A00975" ] |> CyGraph.withSize(800, 400)
=. is a styling mapper and allows to pass data from different sources into the layout.
Here the label attached to each node is rendered as content.
CyGraph.show function will open a browser window and render the input graph there. When working in a notebook context
you want to use
HTML.toEmbeddedHTML for the moment,
myGraph |> CyGraph.show
Should render this chart in your brower:
myFirstStyledGraph |> CyGraph.show
And here is what happened after applying the styles from above:
The project is hosted on GitHub where you can report issues, fork the project and submit pull requests. If you're adding a new public API, please also consider adding samples that can be turned into a documentation. You might also want to read the library design notes to understand how it works.
The library is available under Public Domain license, which allows modification and redistribution for both commercial and non-commercial purposes. For more information see the License file in the GitHub repository.