c# – Representing a graph with passable marks and actions in CSharp – Action reflection hell: good or bad?

I wanted to have a framework to build Petri Nets from C# code. Petri net is a digraph with functional transitions and mark types. In books they tend to look like this:

enter image description here

Here is what I came up with – simple example:

using ServicesPetriNet;
using ServicesPetriNet.Core;
using ServicesPetriNet.Core.Attributes;
using ServicesPetriNet.Core.Transitions;
using static ServicesPetriNet.Extensions;
using static ServicesPetriNet.Core.MarkType;
namespace ServicesPetriNetCore.Core.Tests
{
    public class SimpleAssistLoop : Group<SimpleAtoB>
    {
        public Place A, B, C;

        public Transition AtoC, BtoC;

        (Probabilety(0.5))
        public Transition CtoA;

        (Probabilety(1,1,1,0,1,0))
        public Transition CtoB;

        public SimpleAssistLoop()
        {
            AtoC.Action<OneToOne<Mark>>()
                .In<Mark>(A)
                .Out<Mark>(C);

            BtoC.Action<OneToOne<Mark>>()
                .In<Mark>(B)
                .Out<Mark>(C);

            CtoA.Action<OneToOne<Mark>>()
                .In<Mark>(C)
                .Out<Mark>(A);

            CtoB.Action<OneToOne<Mark>>()
                .In<Mark>(C)
                .Out<Mark>(B);

            Marks = At(A, Create<Mark>());
        }

        public class Mark : MarkType
        {
        }
    }
}

more complicated example:

using System.Collections.Generic;
using System.Linq;
using ServicesPetriNet;
using ServicesPetriNet.Core;
using static ServicesPetriNet.Core.MarkType;
namespace ServicesPetriNetCore.Core.Tests
{
    public class SimpleSummChainAtoF : Group<SimpleSummChainAtoF>
    {
        public Place A, B, C, D, E, F;

        private Transition SummABCtoD, SummDEtoF;

        public SimpleSummChainAtoF()
        {
            SummABCtoD.Action<Add>()
                .In<Mark>(A)
                .In<Mark>(B)
                .In<Mark>(C)
                .Out<Mark>(D);

            SummDEtoF.Action<Add>()
                .In<Mark>(D)
                .In<Mark>(E)
                .Out<Mark>(F);

            Marks = Extensions.At(A, Create<Mark>(5))
                .At(B, MarkType.Create<Mark>(6))
                .At(C, MarkType.Create<Mark>(7))
                .At(E, MarkType.Create<Mark>(8));
        }

        public class Mark : MarkType
        {
            public int value;
        }

        public class Add
        {
            public void Action(List<Mark> marks, out Mark result)
            {
                result = new Mark() { value = marks.Aggregate(0, (i, mark) => i + mark.value) };
            }
        }
    }
}

I wanted for my graphs to be as simple in terms of code letters as possible, yet keep it plainly C# comparable (which they currently are).

And here is the main problem for me:
enter image description here

Because the user nation can have any amount of inputs and outputs like this: Action(T1in ps, ..., TNin ps, out T1out,..., out TNout) and currently is checked only in runtime. To make the things worse currently I support not only the undefined amount of named types (action arguments) but also their mixing with List for in and out. So stuff like this is supported:

    public class Add
    {
        public Mark Action(List<Mark> marks)
        {
            return new Mark() { value = marks.Aggregate(0, (i, mark) => i+mark.value) };
        }
    }

As well as this:

    public class Add
    {
        public Mark Action(Mark fromA, Mark fromB)
        {
            return  new Mark(){value = fromA.value+fromB.value};
        }
    }

So my question is: What would be the way to some-how force check user Action not at runtime?

What is knowledge graph in search engine?

What is knowledge graph in search engine?… | Read the rest of https://www.webhostingtalk.com/showthread.php?t=1814912&goto=newpost

runtime analysis – What is considered an asymptotic improvement for graph algorithms?

Lets say we are trying to solve some algorithmic problem A that is dependent on input of size n.
we say algorithm B that runs in time T(n), is asymptotically better than algorithm C which runs in time G(n) if we have:
G(n) = O(T(n)), but T(n) is not O(G(n)).

My question is related to the asymptotic running time of graph algorithms, which is usually dependent on |V| and |E|.
Specifically I want to focus on Prim’s algorithm. If we implement the priority queue with a binary heap the run-time would be O(ElogV). With Fibonacci heap we could get a run-time of O(VlogV + E).

My question is do we say that O(VlogV + E) is asymptotically better than O(ElogV)?

Let me clarify: I know that if the graph is dense the answer is yes. But if E=O(V) both of the solutions are the same.
I am more interested in what is usually defined as an asymptotic improvement in the case we have more than one variable, and even worse – the variables are not independent (V-1<=E<V^2, since we assume the graph is connected for Prim’s algorithm).

Thanks!

No of ways of selecting k non adjacent nodes in a graph for all k

Suppose there is an undirected connected graph with n<=38 nodes without multiple edges and self loops .
We have to find the no. Of ways to select k nodes such that no two of them are adjacent for all possible k efficiently

co.combinatorics – Is there any maximal 1-planar or 2-planar graph that is not 3-connected

A graph is $k$-planar if it can be drawn in the plane so that each edge is crossed at most $k$ times. A $k$-planar graph $G$ is maximal if $G+uv$ is not $k$-planar for any non-adjacent vertices $u,vin V(G)$.

  • Is there any maximal $1$-planar graph that is not $3$-connected ?
  • Is there any maximal $2$-planar graph that is not $3$-connected ?

I believe those examples exist but didn’t find any references mentioned this.

prove that in complate oriented graph there is triangle

prove that in complate oriented graph there is a triangle .

I tried to use something like red and blue edges. But I can’t figure out how to choose directions of edges and which colour is every edge.

compilers – Haskell Graph Reduction/Graph Representation

I know that under the hood, for a Haskell program, the GHC compiler uses graph reduction for optimization. Is there any way to view this graphical representation of the program? I haven’t been able to find an existing plugin that, given a Haskell program, produces a graphical representation, but I’m relatively new to Haskell.

Some tips on the algebraic graph theory (or graph algebra) problem

I’m looking for some tips on the following problem I faced with. Imagine we have a tree $T$, i.e. acyclic connected graph. We can label its edges using ${0,1}$. Note that these labelings are just functions $f:Erightarrow{0,1}$ where $E$ denotes the set of edges of $T$. Say $T$ contains $q$ edges, then we can produce $2^q$ labelings. Denote $L$ the set of all labelings. Given two elements of $L$, we may define their sum adding corresponding labels modulo 2. Obviously, we will obtain the group $({mathbb{Z}/2mathbb{Z})}^q$.

Now, let’s label the edges of our tree using some injective function $F:Erightarrow{1,…,q}$. Let’s think that the vertices of our tree form the set $V={0,…,q}$ (note that the set of vertices of any tree contains one more element than the set of its edges). For every function $fin L$ we can define the following function $f’:Vrightarrowmathbb{Z}$ labeling the vertices. Put $f'(0)=0$ and after that go inductively: taking an edge $ab$ such that $a$ has been already labeled put $f'(b)=|f'(a)+(-1)^{f(ab)}F(ab)|$. I’m trying to prove that for some $fin L$ the function $f’$ is injective.

The following picture demonstrates what we will have for some tree with labeling $F$ (denoted by red). Using ${+,-}$ instead of ${0,1}$ I’ve firstly built all possible labelings $L$ (the first row). After that I’ve produced the corresponding labelings of the vertices (the second row). The lower row contains values of the obtained labelings. We see that most of them satisfy the injectivity (denoted by green).

enter image description here

Actually, this problem comes from the generalization of the Ringel–Kotzig conjecture I’ve made in my russian article. There 81 of 84 problems were solved, except the well-known conjecture with its equivalent form and the problem I’m sharing here. I mostly will be grateful if you offer some algebraic structures (expanding the group I’ve mentioned) that could be useful for solving the problem.

export graph from HPC to local computer

I am using R on cluster using module load. My plots are actively opened in XQuartz. How can I save these plot in pdf to cluster so that I can then export it to local computer. Thanks!

Unity: Shader Graph and GPU-Instancing?

Unity Version: 2019.4.1f1

Render Pipeline: URP

I created a shader using Unity‘s ShaderGraph, and i want to apply GPU Instancing on this shader, but there is no way to declare per-instance properties inside the shader graph.

Is there a way to make GPU Instancing work on shader graphs’ materials?