小编Sim*_*mon的帖子

使用 Graphviz 创建图形限制表示的深度

我有一个 .dot 文件,它对具有很多级别的二叉决策树进行编码。为了可视化它,我使用命令dot -Tpng sample.dot > sample.png. 但是创建的 .png 是巨大的并且难以理解。所以我想知道是否可以限制从命令行输出文件中呈现的级别数,即我不想修改 -dot 文件,我只想调整 .png 输出的生成方式. 我阅读了文档,但找不到任何内容。

例如,如果我只想要决策树的前三个级别,是否有任何修饰符,例如:dot -Tpng sample.dot > sample.png -L 3

dot graphviz

3
推荐指数
1
解决办法
1858
查看次数

从文件C中读取数字列表

我正在尝试使用scanf将文件中的数字列表读入数组.然后打印出阵列.

该列表由超过一千个数字组成,但是例如它看起来像这样.

70.3
71.5
70.1
71.1
71.8
71.6
72.0
72.0
71.8
Run Code Online (Sandbox Code Playgroud)

我有这么多,但它只打印出一个难以理解的数字列表.

int main () {

FILE *temp;
temp = fopen("temp.txt", "r");
int Readings[2881];
int Temps;

    if (!temp)
    {
        printf("Cannot open the file!\n");
        return 0;
    }

for (Temps = 0; Temps < 2881; Temps++)
{
    fscanf (temp, "%d", &Readings[Temps]);
}

for (Temps = 0; Temps < 2881; Temps++)
{
    printf("The readings are %d\n", Readings[Temps]);
}

fclose(temp);

return 0;
}
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

c arrays

0
推荐指数
1
解决办法
69
查看次数

Python for循环超出范围时出错

我正在写一个PsychoPy程序(一个用于使用Python进行心理学实验的软件)并且不断获得"列表索引超出范围"错误.该问题出现在"if already_used_values [a] == value:"的行上.我可以看到为什么会发生这种情况的唯一可能原因是因为already_used_values从一个空列表开始; 但是,我认为如果列表为空,我通过说返回False来解决这个问题.以下是相关代码供参考.

already_used_values = []#integers in order to sort sounds
sorted_sounds = []#note that these are not 'sorted', they are randomized each time
answer_key = []
def already_used(value):#returns true if value in array of sounds has been used
    if len(already_used_values) == 0:
        return False
    for a in already_used_values:
        if already_used_values[a] == value:
            return True
    return False
def pick_random_value(upLim):
    return random.randint(0,upLim-1)

def pick_sound(sound_list):#picks a sound randomly from list_of_sounds 
    new_value = pick_random_value(len(sound_list))
    while(already_used(new_value)):
        new_value = pick_random_value(len(sound_list))
    already_used_values.append(new_value)
    return …
Run Code Online (Sandbox Code Playgroud)

python loops psychopy

-1
推荐指数
1
解决办法
56
查看次数

标签 统计

arrays ×1

c ×1

dot ×1

graphviz ×1

loops ×1

psychopy ×1

python ×1