Is there a way to 2 straight edges between nodes? - vis.js

Does anyone know a way to get two straight edges between nodes so that both are visible? And with different styles on each?
I have only found ways to get multiple edges with curves; 2 straight edges always hover one another.

Related

Creating a network graph with set node positions and concentrated edges with both circleheads and arrowheads in R

I've been trying to find a way to replicate the following network graph format in R using DiagrammeR/GraphViz, but without success (ignore the thick black arrow on N1): https://i.stack.imgur.com/oHpQz.png
The graph is a directed graph and each edge in a certain direction either ends with an arrowhead (-->) if the edge value is positive, or a circle/odot (--o) if the edge value is negative. Between a pair of nodes (ex. N1 -- A1), there can be an edge N1 --> A1 and an edge A1 --o N1, and these need to be concentrated so that the two edges look like one line with an arrowhead on one end and a circlehead on the opposite end (like this: o--->). These cannot be parallel or look like two edges ideally.
Another requirement is that the nodes have to be in very specific positions and remain there throughout model simulations where edges might change. From what I have tried and the documentation I have read, this is not possible to do in DOT format, but is possible in neato format.
This is where I get a problem. In neato, I can align the nodes exactly where I want them by defining their x,y positions. However, when I use concentrate = true to create the o---> edge from two otherwise parallel edges, only one type of arrowhead remains. So an edge that's supposed to look like o---> ends up looking like ---> or o---.
This is not a problem in DOT format as concentrate = true does what I want it to do, but in DOT I cannot assign exact node positions. I have tried getting around this using node ranks but without much luck. It seems to stack nodes I want in different ranks within the same rank. As well, concentrate = true doesn't seem to work for edges between nodes within the same rank, as it leaves them as two separate curved edges ---> and o--- without concentrating them.
The reason why I need this to work is because I'm running model simulations where the edges change, and I need to generate hundreds of such graphs. For easy comparison, the nodes need to stay in the same place for consistency.
This is the closest I could come up with using neato format (nodes are positioned the way I want but it's not showing the proper o---> for all the black edges minus self-edges; red edges are true one-way links): https://i.stack.imgur.com/YJBY7.jpg
If only the edges showed up as the proper o---> format, this would be perfect for my needs. If you know of any way to fix this issue using DiagrammeR/GraphViz, or even another program, I would be so grateful. Thanks!
You probably don't need concentrate. Look at arrowtail and dir (https://www.graphviz.org/doc/info/attrs.html#d:arrowtail and https://www.graphviz.org/doc/info/attrs.html#d:dir) and neato -n
digraph c {
graph[label="can neato do the work?"]
node[shape=circle]
a [pos="100,100"]
b [pos="200,100"]
c [pos="300,100"]
a->b [dir=both arrowtail=odot]
c->c [dir=both arrowtail=odot arrowhead=none]
}
Giving:

Implementing BFS on same level vertexes of a graph data structure

I'm trying to understand graphs in data structures and got struck here in understanding. can anyone help in understanding this approach. Graphs allow multiple vertexes to connect to any arbitrary vertex without any constraints. while inserting edges, it is possible the vertex to be connected may be on the same level or at any below levels.
In the above figure, BFS through graphs gives 5,6,7 in one and 5,7,6 in another. There is no constraint to get the same level vertexes on graph. How is this identified?
Please let me know as none of the resources point that differenece. Both 6,7 are unvisited from 5,if one refers to 7 and adds to queue(image-1). BFS will be violated.
EDIT:
In the above BFS Example image we have 5 vertexes and if we start from 5 we can either traverse to 6,7 as adjacent nodes. if we are trying to implement BFS here then we can either add 6 or 7 to queue but 7 is the valid one as it is at the same level. How is this identified?
The two drawings you posted show identical graphs: the same three vertices are connected with the same three edges. Graphs don't have levels. They don't keep track of any type of edge ordering, nor the horizontal or vertical layout of the vertices when the graph is drawn.
A BFS starting from vertex 5 could visit either 6 or 7 next. Either order is a valid BFS traversal.

Eliptic looking graph

What options should I use for making my graph looking like an Elipse ? I was messing with the hierarchical option under the layout module, but I've not gotten nowhere near my desired shape.
My graph is left to right, left node group connects to middle one, and middle one connects to the right one. It can be perceived as this image below.
Can someone point me in the right direction ? Thanks for your expertise
As for the elliptic shape around the nodes and edges, you can either set a background image to your graph area or create a node of large size (but this way you may have troubles with node repulsion, though). Unfortunately, there's no way to make sure that all the nodes will always be inside the ellipse (unless you access the vis' canvas and deal with it on low level or do some other hackery).
Also AFAIK it is impossible to create those wavy edges, but for those rounded ones you may want to use repulsion physics instead of barnesHut. See also physicsConfiguration example.

Algorithm for placing nodes in a graph

I have been trying to create an algorithm that can create a graph. It is not a tree graph as nodes can have multiple parents, more like an activity diagram. My problem is with placing nodes on the x axis, making sure that they do not overlap each other. I have been looking around for months now, but I have been unable to find any information relevant to this kind of graph. So I where wondering if some of you people might know of an algorithm that can solve this problem, or an idea on what approach I should take.
Here you see my problem: The red nodes are overlapping other nodes
My best approach right now is where i add it all to row:
With this approach will the tree above look like this.

Hidden edges in Graphviz

I'm trying to create a graph using Graphviz (complied with neato), and I would like to place nodes in specific locations. For this, I'm specifying exact edge lengths for all edges. However, I don't want all edges to be visible in the final image.
Do you know of any way to hide edges? I should mention that I tried coloring the edges white, but what happens is that I get white lines painted over the graph nodes - it's not very aesthetic...
It can be done using
nodeA -> nodeB [style=invis]
I found out that another way to go is to define:
outputorder="edgesfirst"
for the graph.

Resources