7
$\begingroup$

I want to plot the relationship of all fucntions in Mathematica, maybe using Graph or force-directed-graph in D3.js

k = 
  DeleteCases[
    WolframLanguageData[All, {"CanonicalName", "RelatedSymbols"}], {_, _Missing}];
k = MapAt[CanonicalName, k, {All, 2}];
data = 
  DeleteDuplicates[
    Sort /@ Flatten[Thread[#[[1]] \[UndirectedEdge] #[[2]]] & /@ k]];
GraphPlot[data, VertexSize -> Tiny, ImageSize -> Full]

enter image description here

However, the figure is too big. Is there some method to zoom in on it and tooltip the vertices?

I tried Tooltip, However, it did not give a plot.

Graph[Tooltip[#, #] & /@ VertexList[data], data]

enter image description here

And how can I to use colors to distinguish these functions by catogeries such as Audio, Image and Core language?

enter image description here

Maybe I could use machine learning to distinguish these functions I tried but it didn't work out so good.

space = 
  Thread[
    VertexList[data] -> 
      DimensionReduce[
        FeatureExtract[VertexList[data], {"SegmentedWords", "TFIDF"}], 
        1]];
space[[All, 2]] = Normalize[Flatten@space[[All, 2]]];
NumberLinePlot[space[[All, 2]]]

enter image description here

UPDATE:

Version: 12.1.1

These was already a demo in the NestGraph's document.

enter image description here

$\endgroup$
6
$\begingroup$

Technical support CASE:4620942

$Version

(* "12.1.1 for Mac OS X x86 (64-bit) (June 19, 2020)" *)

Clear["Global`*"]

As suggested by flinty, running code from the documentation

graph = WolframLanguageData["Cos", "RelationshipCommunityGraph"]

enter image description here

The labels for the vertices do not render properly

Show[graph, ImageSize -> Large]

enter image description here

As a workaround, manually fix the labels

graph /. Style[lbl_, _List] :> lbl

enter image description here

| improve this answer | |
$\endgroup$
1
$\begingroup$

Define a function that can extract neighbors with radius r around vertex n:

subgraph[g_, n_, r_] := Subgraph[g, AdjacencyList[g, n, r]~Join~{n}]

Let's take a look at the neighbors whose distance to the Sin function is 2

subg = subgraph[Graph[data], "Sin", 2];
GraphPlot[HighlightGraph[subg, {"Sin"}], VertexLabels -> "Name", ImageSize -> Large]

enter image description here

Export the graph data that will use in the following HTML:

json = {"nodes" -> 
    Table[{"id" -> i, "group" -> 1}, {i, VertexList@subg}], 
        "links" -> 
    Table[{"source" -> i[[1]], "target" -> i[[2]], "value" -> 1}, {i, EdgeList@subg}]};
Export["miserables.json", json]

Download the D3.js script index.html from D3.js v4 Force Directed Graph with Labels

Then in the terminal type the following (python3): python -m http.server

Then open http://localhost:8000/ in Chrome, the figure can drag the vertex interactively

enter image description here

But for the whole big graph, the D3.js can't handle it...

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.