小编Dzi*_*ski的帖子

如何使用 Java 进行拓扑排序(依赖解析)

描述

该问题的目的是实现一个接口,该接口将根据任务的依赖关系信息对任务列表进行排序。例如,如果任务 A 依赖于任务 B 和 C,则这意味着要开始处理任务 A,必须首先完成任务 B 和 C。我认为它应该像有向图结构。

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * The task class represents a certain activities that must be done as the part of the project planning
 */
class Task {

    /**
     * Unique name of the activity
     */
    private String name;

    /**
     * A list of names of the activities that must be completed in order to be able to start the current activity
     */
    private List<String> predecessors;

    public …
Run Code Online (Sandbox Code Playgroud)

java graph directed-graph jgrapht guava

5
推荐指数
1
解决办法
3959
查看次数

标签 统计

directed-graph ×1

graph ×1

guava ×1

java ×1

jgrapht ×1