How to deal with parallel edges between two vertices in cycle detection using BFS in an undirected graph?

I am new to Programming and learning Algorithms and was studying BFS when I read that BFS could be used for cycle detection. I tried to implement the same on an undirected graph G with Adjacency List Representation. What I did is as follows:

• Do a simple BFS Traversal using a Queue while maintaining the parent node of nodes enqueued in the queue.

• If I come across a node u that has a neighbor v such that v is already visited but v is not the parent of u then that means there is cycle in the graph.

Pseudocode:

#adjList is the adjacency list given as a dictionary #myQueue is a double-sided queue containing node and its parent node ([Node, parNode]) #visited is a set containing visited nodes  while(myQueue):     currNode, parNode = myQueue.pop() #dequeue operation     visited.add(currNode) #Marking currNode as visited     for childNode in adjList[currNode]: #Traversing through all children of currNode         if currNode not in visited:             myQueue.appendleft([childNode, currNode]) #Enqueue operation         else:             if childNode!=parNode: #Main logic for cycle detection                 print('CYCLE DETECTED')                 break 

The above approach is working except in cases when I have more than 1 edge between 2 vertices for e.g. in following case we have 2 edges between vertices 0 and 1:

Graph containing cycle

Adjacency list of above graph is: adjList = {0:[1, 2], 1:[0], 2:[0]}. Here we can clearly see that the graph contains a cycle but above algorithm is not able to detect the same because when BFS will reach vertex 1, vertex 0 is already visited but vertex 0 is also the parent of vertex 1 so this cycle will go undetected.

My question is how I can modify above algorithm to detect such cases?

Edit: I tried the same logic on directed graphs also, and I am facing similar problem i.e. case when I have a directed edge from vertex 0 to vertex 1 and another directed edge from vertex 1 to vertex 0

Explain this Graph Matching solved in Linear Time

I’m interested in a better explanation about the paper Computing Optimal Assignments in Linear Time for Approximate Graph Matching.

The graph edit distance is approximated by assignments in linear time.

Briefly speaking there is an embedding of optimal assignment costs into a Manhattan metric: $ φ_c(A) = [A_{uv}^← · w(uv)]_{uv∈E(T)}$ . The Manhattan distance between these vectors is equal to the optimal assignment costs between the sets.

The problem is: it is not throughly explained how I find $ A_{uv}^←$ and how I use Weisfeiler-Lehman to label the vertices of a tree in the following figure:

enter image description here

Please, explain how I find $ A_{uv}^←$ and how I label that tree.

How to encode reachability in a graph with walls as a SAT problem

Suppose we have a graph that represents a grid of cells. We are given a cell to start in and a cell that’s the destination. There are cells that we cannot enter and they are known as walls. Finally we may only move to adjacent cells (diagonal movements are not allowed).

My question is how would one encode this problem in CNF to be solved by a SAT solver?

For example, let the graph represent the following 2 x 3 grid:

0 1 0 0 0 0 

where 0-cells are cells we may be in or move to and 1-cells are walls. Suppose we start in (0, 0) and want to move to (0, 2). Then there is a path.

On the contrary, consider another 2 x 3 grid with the same start and destination positions:

0 1 0 0 1 0 

Then this graph does not have a path from start to destination.

Clearly we may run BFS on the graph and if there’s a path we can encode it as a trivially satisfiable CNF, or if there isn’t then encode it as a trivially unsatisfiable CNF. For example, $ A$ , or, $ A \land \neg A$ . However, the point of my exercise is to encode the path existence in CNF.

This is indeed part of my homework. I have been stuck for a while now. Some help on this problem would be greatly appreciated.

Finding shortest path in directed graph

Suppose you are on a road trip driving from point A to point B. There are several scenic routes you would like to drive through but they are time-consuming so you only want to drive through exactly one. Design a reasonably efficient algorithm that, given a directed graph G = (V, E), a subset S ⊆ E, a starting vertex A and an ending vertex B, will determine if there exists a path from A to B that goes through exactly one edge in S. (reasonably efficient correct algorithm (with correctness proof), Time analysis, The efficiency of your algorithm)

How can I hash an attributed graph?

I am interested in solving the following problem using a learning to hash algorithm:

I’ve got several attibuted graphs (a graph with node and edge labels – you can think about that as a description logic query) and I want to perform similarity search between a query and a document (both represented as an attributed graph).

After googling a lot, I found only a Kernelized Locality-Sensitive Hashing algorithm (KLSH) solution, the following one: Kernelized Hashcode Representations for Relation Extraction.

Locality-Sensitive Hashing demands more bits than a learning algorithm to represent data. It’s not an ideal solution.

Question:

Is there a learning to hash algorithm to perform similarity search for description logic queries?

How to create SharePoint list item with Microsoft Graph API?

I am trying to create list items with Microsoft Graph API to a SharePoint endpoint. My URL is as follows:

https://graph.microsoft.com/v1.0/sites/{id}.sharepoint.com:/sites/{name of the site}:/lists/{list_id}/items 

Calling this URL with POST, and a body like this:

{     "fields": {         "FileLeafRef": "757391.pdf",         "ContentType": "Document",         "Application_x0020_Name": "ABC",     } } 

It is giving error as "message": "Files and folders should only be added to a DocumentLibrary via the OneDrive API"

Can some one help on this, how to fix this issue? Here I am trying to create metadata for document, with in a list from Dell Boomi.

There is a difference between malware detection using automata and family behavior graph?

I have a question,

There is a difference between dynamic malware detection using automata and family behavior – graph?

I think that they are both relying on API function calls but I don’t understand if there is any major difference between them.

Please help me,

if you’re not sure what I’m talking about:

automata – https://www.researchgate.net/publication/309710040_Detecting_Malicious_Behaviors_of_Software_through_Analysis_of_API_Sequence_k-grams

family behavior – graph – https://drive.google.com/open?id=1dOZ80FcaBiDHRDW4kusdxXGZw2C9aXfK

of course, they are free

first one – just click on Request full-text and it will download the pdf files. the second one is google drive link.

Thank you.

Graph neural network

I’m trying to build GNN model that classify images , the first step is to model each image with graph , each node represents one pixel , now how can I define the edges in my case ? does the spatial distance will be okay ?

FInd a graph on a vertex set similar to another graph

I am looking for a possible algorithmic solution to this problem, but I can’t figure out any.

Let’s say I have a weighted graph (call it G); each vertex on this graph represents a point in a plane, and each edge has the distance as its weight.

Now I have another set of vertex, let’s call it S, representing points in the same plane.

My goal is to find a new graph whose vertex are taken from S, and that should be “as similar as possible” to the graph G. For me similar means that reciprocal positions and distances for connected vertices must be similar as much as possible to those of correspondent vertices in G.

Maybe such an algorithm already exists but I did not manage to find it.

Thank you for your time!