現在Eclipseで問題に取り組んでいます。データ構造 weightedQuickUnionFind
私が持っているもの:
- ユーザーの ID を含む別の .txt ファイル内のデータのリスト。例:
0 5
0 2
1 3
1 2
2 5
3 7
これが基本的に言っていることは、ID 0 のユーザーが ID 5 のユーザーなどとソーシャル ネットワークで接続されているということです。0 が 2 に接続され、1 が 2 に接続されている場合、0 は 2 に接続されています。とにかく、このリストを使用して、Main クラスと WeightedUnionFind クラスを作成しました。私のメインクラスでは、質問に答えるのに役立ついくつかのメソッドを公開しました。
- 各個体に何人が接続しているか (つまり、0 に接続しているのは何人か)、何人が接続していないか?
- ID のグループはいくつ接続されており、最大のグループは何ですか?
これを次から次へと質問であふれさせたくないので、出発点を探しているだけです。
私が言ったように、私はこれまでメソッドをシェルアウトしただけで、これらのメソッドを .txt ファイルに実装するための出発点が必要なだけです。
/**
*numberOfIndividuals() method Finds # of distinct individual in data
*ie. how many users are there?
*/
public static int numberOfIndividuals()
{
return -1;
// not implemented yet
}
/**
* Get the number of distinctly connected groups of individuals.
*
*/
public static int numberOfGroups()
{
return -1;
// not implemented yet
}
と呼ばれる別のクラスを作成しました
public class WeightedQuickUnionUF {
//which I incorporate the methods find, count, union etc.
}
これが明確だったことを願っています。