我的程序返回一个元组列表,它们代表图形的边缘,形式为:
[(i, (e, 130)), (e, (i, 130)), (g, (a, 65)), (g, (d, 15)), (a, (g, 65))]
Run Code Online (Sandbox Code Playgroud)
所以,(i,(e,130))意味着'i'连接到'e'并且距离130个单位.
类似地,(e,(i,130))意味着'e'连接到'i'并且距离130个单位.基本上,这两个元组代表了同样的东西.
我如何从此列表中删除其中任何一个?期望的输出:
[(i, (e, 130)), (g, (a, 65)), (g, (d, 15))]
Run Code Online (Sandbox Code Playgroud)
我尝试编写一个equals函数.这有什么帮助吗?
def edge_equal(edge_tuple1, edge_tuple2):
return edge_tuple1[0] == edge_tuple2[1][0] and edge_tuple2[0] == edge_tuple1[1][0]
Run Code Online (Sandbox Code Playgroud) 在setUser方法中,我试图从我的数据库中读取数据,我将用它来创建User,Worker,Manager或Administrator的实例.我也知道以下三行代码是不正确的,但它们不是提出任何错误,所以现在可以忽略它们.
String name = mUserDatabase.child(uniqueId).child("name").orderByValue().toString();
int zip = mUserDatabase.child(uniqueId).child("zipcode").orderByValue().hashCode();
String phone = mUserDatabase.child(uniqueId).child("phone number").orderByValue().toString();
Run Code Online (Sandbox Code Playgroud)
令我困惑的是onDataChange是在onActivityResult中输入的,而不是在setUser中输入的.我无法理解为什么没有在setUser中输入onDataChange.firebase引用是正确的,我导航到使用typ.toString()记录的url,它转到了正确的条目.我也设置了公共权限,如果这是相关的.我也连接到互联网.我还查看了类似问题的其他答案,这些答案的答案与问题无关.可能会发生什么会导致我感激任何帮助!
package edu.gatech.cs2340.waterfall.controller;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import com.firebase.ui.auth.AuthUI;
import com.firebase.ui.auth.IdpResponse;
import com.firebase.ui.auth.ResultCodes;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.Query;
import com.google.firebase.database.ValueEventListener;
import java.util.Arrays;
import edu.gatech.cs2340.waterfall.R;
import edu.gatech.cs2340.waterfall.model.Administrator;
import edu.gatech.cs2340.waterfall.model.Manager;
import edu.gatech.cs2340.waterfall.model.Model;
import edu.gatech.cs2340.waterfall.model.User;
import edu.gatech.cs2340.waterfall.model.Worker;
import static android.R.attr.data;
import static android.R.attr.dateTextAppearance;
import static android.R.attr.type;
public class WelcomeActivity extends …Run Code Online (Sandbox Code Playgroud)