Convert python to C# Revit API

Question:

I am beginer in C# and Api, so it some difficult for me to convert useful solutions to my code.
Please help understand how do it?
In goal need find shortest way. Have some elements which connected each other by connectors. With this in hand I can find all possible ways of way(code of may implementation below), but cant do dict with two keys for self.weights.

Origin of Python code

start = IN[0]
end = IN[1]
edges = IN[2]

graph = Graph()

for edge in edges:
    graph.add_edge(edge[0],edge[1],1)



class Graph():
    def __init__(self):
        """
        self.edges is a dict of all possible next nodes
        e.g. {'X': ['A', 'B', 'C', 'E'], ...}
        self.weights has all the weights between two nodes,
        with the two nodes as a tuple as the key
        e.g. {('X', 'A'): 7, ('X', 'B'): 2, ...}
        """
        self.edges = defaultdict(list)
        self.weights = {}
    
    def add_edge(self, from_node, to_node, weight):
        # Note: assumes edges are bi-directional
        self.edges[from_node].append(to_node)
        self.edges[to_node].append(from_node)
        self.weights[(from_node, to_node)] = weight
        self.weights[(to_node, from_node)] = weight

How i find connector and make dictionary of all possible next nodes

foreach (Connector con in cset)
{
    if (con.IsConnected)
    {
        string key = con.Owner.Id.ToString();

        if (conn_dic.ContainsKey(key))
        {
            List<Connector> conns = conn_dic[key];
            conns.Add(con);
            conn_dic[key] = conns;
        }
        else
        {
            conn_dic.Add(key, new List<Connector>() { con });
        }
    }
}
Asked By: Bender__SS

||

Answers:

The Revit API is completely .NET based. All .NET source code is converted to intermediate language, IL (Wikipedia). You can decompile the intermediate language to recreate the original source code. This enables you to easily and effectively convert the source code from one .NET language to another, for instance from Python to C# or VB.NET. This possibility is used by numerous .NET decompilers.

Answered By: Jeremy Tammik