Search code examples
pythonalgorithmagent

Picking the best element out of a list of dominance


so I'm working on an argumentation system, and my goal is to pick the best expert who would make my system less controversial. I've implemented the algorithms, and got this as an answer:

EX1  dominates  EX5
EX2  dominates  EX1
EX2  dominates  EX5
EX4  dominates  EX1
EX4  dominates  EX5

what I want to do now, is to order these experts ( from EX1 to EX5 ) using the dominance results I got, so I can pick the best one. I found out a way to do it, which is calculating the minimal FAS, then use the topologic order, but I want to know if there's an algorithm that gives me the exact result ( in this example, the best experts are EX4 and EX2 ).

Thanks in advance.


Solution

  • Like @Suparshva suggested in the comments, I've made a graph where arguments are nodes and the edges represent the dominance and i retrieve the nodes with the lowest in degree.

    the following algorithm is written in python and the graph is instantiated using the networkx library.

    d=nx.DiGraph()
    d.add_nodes_from([expert.name for expert in experts])
    
    for exp in experts:
        for expert in experts:
                if exp.persist_dominate(expert) and exp != expert:
                    d.add_edge(exp.name,expert.name)
    
    print([elem[0] for elem in d.in_degree if min(d.in_degree, key=lambda x: x[1])[1] == elem[1]])