コード例 #1
0
 public bool AddToWeight(Note note, double to_add)
 {
     if (IsConnected(note))
     {
         connections[NoteUtil.NoteHash(note)].weight += to_add;
         return(true);
     }
     return(false);
 }
コード例 #2
0
 // Returns true if adding the node was successful
 // Returns false if the Note in the NoteNode being added is already connected
 public bool AddConnection(NoteNode note, double weight)
 {
     if (!IsConnected(note.GetNote()))
     {
         connections[NoteUtil.NoteHash(note.GetNote())] = new Edge(note, weight);
         return(true);
     }
     return(false);
 }
コード例 #3
0
 // Returns boolean representing success of the operation
 public bool SetWeight(Note note, double new_weight)
 {
     if (IsConnected(note))
     {
         connections[NoteUtil.NoteHash(note)].weight = new_weight;
         return(true);
     }
     return(false);
 }
コード例 #4
0
        private void ModifyConnectionWeight(Note from, Note to, double by)
        {
            double distribute_to_rest = -((1.00 / (NoteUtil.NOTE_COUNT - 1)) * by);

            nodes[NoteUtil.NoteHash(from)].AddToWeight(to, by);

            for (int i = 0; i < NoteUtil.NOTE_COUNT; ++i)
            {
                if (i == NoteUtil.NoteHash(to))
                {
                    continue;
                }

                nodes[NoteUtil.NoteHash(from)].AddToWeight(nodes[i].GetNote(), distribute_to_rest);
            }
        }
コード例 #5
0
        public NoteGraph()
        {
            double initial_weight = 1.00 / 22.00;

            for (int i = 0; i < NoteUtil.NOTE_COUNT; ++i)
            {
                nodes[i] = new NoteNode(NoteUtil.GetNoteAtIndex(i));
            }

            for (int i = 0; i < NoteUtil.NOTE_COUNT; ++i)
            {
                for (int k = 0; k < NoteUtil.NOTE_COUNT; ++k)
                {
                    nodes[i].AddConnection(nodes[k], initial_weight);
                }
            }
        }
コード例 #6
0
 private bool IsConnected(Note note)
 {
     return(connections[NoteUtil.NoteHash(note)] != null);
 }
コード例 #7
0
 public double GetEdgeWeight(Note note)
 {
     return(connections[NoteUtil.NoteHash(note)].weight);
 }