maxitg / SetReplace

C++/Wolfram Language package for exploring set and graph rewriting systems
MIT License
219 stars 45 forks source link

Meassure dimensionality of (hyper) graph #306

Open freemin7 opened 4 years ago

freemin7 commented 4 years ago

The problem

In his presentation yesterday Steven Wolfram talked about the (fractional) dimensionality of hyper graphs. The documentation of this package does not show how calculate/plot them.

Possible solution

A example how to calculate those would be great. Note that these numbers depend a selected subgraph. A function that takes the new subgraph and repeatably does that calculation of dimensionality would be a quality of life feature

Alternative solutions

There is some extra package i don't know about.

Additional context

The end goal would generate plots like this: https://youtu.be/rbfFt2uNEyQ?t=1643

GetJonWithIt commented 4 years ago

https://resources.wolframcloud.com/FunctionRepository/resources/GraphNeighborhoodVolumes

Note, in general: https://www.wolframcloud.com/obj/wolframphysics/Tools/guide-page

-Jonathan

freemin7 commented 4 years ago

Thank you for the pointer but https://resources.wolframcloud.com/FunctionRepository/resources/GraphNeighborhoodVolumes doesn't work for (Hyper) Graohs generated by SetReplace.

maxitg commented 4 years ago

There is also HypergraphNeighborhoodVolumes in Function Repository.

Also, if you go to the corresponding section in the Technical Introduction, you can click on the plot to copy the input (it takes a few minutes to compute in this case):

HypergraphDimensionEstimateList[hg_] := 
  ResourceFunction["LogDifferences"][
   MeanAround /@ 
    Transpose[
     Values[ResourceFunction["HypergraphNeighborhoodVolumes"][hg, All,
        Automatic]]]];
ListLinePlot[
 Select[Length[#] > 3 &][
  HypergraphDimensionEstimateList /@ 
   Drop[WolframModel[{{x, y}, {x, z}} -> {{x, z}, {x, w}, {y, w}, {z, 
        w}}, {{1, 2}, {1, 3}}, 16, "StatesList"], 4]], Frame -> True, 
 PlotStyle -> 
  WolframPhysicsProjectStyleData["GenericLinePlot", "PlotStyles"]]
image

(ResourceFunction["WolframModel"] and ResourceFunction["WolframPhysicsProjectStyleData"] call this package, but they introduce overhead, so I replaced them with the package functions in the above.)

maxitg commented 4 years ago

And also, yes, we do need a well-tested, easy-to-use function in SetReplace which would measure volumes and dimensionalities (including automatic averaging with error bars, sampling, etc.).

We also need a function that would color edges in the hypergraph itself based on the local dimensionality, so that we can see how it varies in space, probably as a special value for the PlotStyle option in WolframModelPlot: #307.

freemin7 commented 4 years ago

What is the role of Drop and how to choose an appropriate value?

maxitg commented 4 years ago

Drop removes the first four states from the plot, because they are too small to measure dimension in a meaningful way, and just make the left-hand side of the plot too crowded. It actually does not change anything here because Select[Length[#] > 3 &] takes care of that anyway.

You can just use this code (3 here means you should have a hypergraph radius of at least 3, which is a reasonable minimum for any rule):

HypergraphDimensionEstimateList[hg_] := 
  ResourceFunction["LogDifferences"][
   MeanAround /@ 
    Transpose[
     Values[ResourceFunction["HypergraphNeighborhoodVolumes"][hg, All,
        Automatic]]]];
ListLinePlot[
 Select[Length[#] > 3 &][
  HypergraphDimensionEstimateList /@ 
   WolframModel[{{x, y}, {x, z}} -> {{x, z}, {x, w}, {y, w}, {z, 
       w}}, {{1, 2}, {1, 3}}, 16, "StatesList"]], Frame -> True, 
 PlotStyle -> 
  WolframPhysicsProjectStyleData["GenericLinePlot", "PlotStyles"]]