Plotting a graph with elements having more than one join

I can't immediately think of a way to describe a graph with nodes that must have more than one input.

A normal directed graph would be a set of instances of these classes:

class Edge
{
  public int Weight { get; set; }
  public Node Node { get; set; } 
}

class Node
{
  public object Value { get; set; }
  public List<Edge> Outs { get; set; }
}

But what if some nodes must have more than one input (like transistors)? How to describe the structure of such a graph? The first thing that comes to mind is to make a collection of three nodes. But maybe there is a more interesting approach?

UPD:

I tried to portray my wish is graphically displayed and I realized that "the first thing that comes to mind" is correct.

enter a description of the image here

In the first picture, there is no graph at all, the node of the graph should have all the inputs arranged as one. The second picture just schematically shows the transistor, but I can't think of how to describe it from the point of view of architecture. Adding a collection of nodes to the graph is not a problem. And the bypass will be correct (the output from the transistor will have a weight of 1 or 0, depending on, what came), but the problem turns out to be how I can then read this graph. After all, when traversing I will get a set of nodes, how do I understand that I am dealing with a transistor?

Author: iRumba, 2018-12-12

1 answers

A digraph vertex cannot have any "inputs". Therefore, it is not necessary to make a graph, but something else.

For example, when modeling electrical circuits, node points and elements are usually distinguished:

class Junction
{
    public List<Element> ConnectedElements { get; }
}

class Element
{
    public ElementType Type { get; }
    public List<Junction> ConnectedJunctions { get; }
}

You can also separate the inputs and outputs of the elements, as well as the connections between the nodes.:

class Junction
{
    public List<Connection> Connections { get; }
}

class Connection 
{
    public Junction From { get; }
    public Junction To { get; }
}

class Inlet : Junction
{
    public Element Element { get; }
}

class Outlet : Junction
{
    public Element Element { get; }
}

class Element
{
    public ElementType Type { get; }
    public List<Inlet> Inlets { get; }
    public List<Outlet> Outlets { get; }
}
 1
Author: Pavel Mayorov, 2018-12-12 07:02:17