Hello there,
I’ve been working on a project in which I have to work with a non-directed graph.
I have created an abstract Node class, which contains a nested Class, called AdjacentNode and a List called adjacentNodes.
AdjacentNode contains two int NID and SID, NID being the node ID and SID being the sub grid ID/partition ID
public abstract class Node : MonoBehaviour
{
[System.Serializable]
public class AdjacentNode
{
int NID;
int SID;
}
public List<AdjacentNode> adjacenNodes;
}
The reason for the nested Class is, that I want to be able to acces the two ints in the Inspector.
Originally, instead of the nested class I used (int, int) tuples. Those were not Serialized in the inspector though, which makes them useless in the project context.
My Graph is made of multiple partitions, each one being of the class SubGrid.
SubGrid contains a method, called InitializePartialNodeAdjacencyList() which is supposed to simply initialize a two dimensional list, where the outer list index represents the ID of a node in the sub grid and the inner List represents the List of each node adjacent to the node index: so list[1] would give us the List of all nodes that are adjacent to the node with the ID 1 in that sub Grid and list[1][3] would give us the the third node entry in the adjacency list of node #1.
public class SubGrid : MonoBehaviour
{
public List<List<Node.AdjacentNode>> adjacencyList;
public void InitializePartialAdjacencyList()
{
//Initializes list partially
}
}
Alright, that’s the explanation of what I’m trying to do, here comes the problem:
In InitializePartialAdjacencyList() I want to check if one of the entries of adjacencyList[someIndex] fullfills a condition:
adjacencyList[1].Contains(x => x.NID == 0);
Sadly though, i get the same Error as in the title: “Cannot convert lambda expression to type ‘Node.AdjacentNode’ because it is not a delegate type [Assembly-CSharp]csharp(CS1660)”
Would anybody be so kind as to help me out?
I’ve been googling like hell, but it doesn’t seem, like anybody has had a similar problem to mine.
I’m getting kind of frustrated here.
I’m also fine with using alternatives to the way that I’m trying to pull this off, but I would love to understand, what the problem is and where it’s coming from.
Thanks in advance